From 0bb96ecf1276ccdbe3fef3d765f19daf6345a3c3 Mon Sep 17 00:00:00 2001 From: "kehaoyuan@ghzhushou.com" Date: Fri, 8 May 2020 16:19:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E9=80=9A=E7=9F=A5=E8=B7=B3=E8=BD=AC=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/824=20?= =?UTF-8?q?=EF=BC=882=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gamecenter/receiver/DownloadReceiver.java | 44 +------------------ .../main/java/com/halo/assistant/HaloApp.java | 1 + 2 files changed, 3 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/com/gh/gamecenter/receiver/DownloadReceiver.java b/app/src/main/java/com/gh/gamecenter/receiver/DownloadReceiver.java index 479d1e32eb..c98fae810f 100644 --- a/app/src/main/java/com/gh/gamecenter/receiver/DownloadReceiver.java +++ b/app/src/main/java/com/gh/gamecenter/receiver/DownloadReceiver.java @@ -3,20 +3,10 @@ package com.gh.gamecenter.receiver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.os.Bundle; -import androidx.core.content.ContextCompat; -import com.gh.common.util.RunningUtils; -import com.gh.gamecenter.DownloadManagerActivity; -import com.gh.gamecenter.MainActivity; -import com.gh.gamecenter.SplashScreenActivity; -import com.gh.gamecenter.eventbus.EBSkip; - -import org.greenrobot.eventbus.EventBus; +import com.gh.common.util.DirectUtils; import static com.gh.common.util.EntranceUtils.ENTRANCE_DOWNLOAD; -import static com.gh.common.util.EntranceUtils.KEY_ENTRANCE; -import static com.gh.common.util.EntranceUtils.KEY_TO; /** * Created by LGT on 2016/10/10. @@ -26,36 +16,6 @@ public class DownloadReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - - if (RunningUtils.isRunning(context)) { - // 助手正在运行 - if (RunningUtils.isEqualsTop(context, DownloadManagerActivity.class.getName())) { - if (RunningUtils.isApplicationBroughtToBackground(context)) { - // 这里是指从后台返回到前台 前两个的是关键 - - Intent download = new Intent(context, DownloadManagerActivity.class); - Intent main = new Intent(context, MainActivity.class); - main.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); - main.setAction(Intent.ACTION_MAIN); - main.addCategory(Intent.CATEGORY_DEFAULT); - ContextCompat.startActivities(context, new Intent[]{main, download}); - } - // 切换到游戏下载fragment - EventBus.getDefault().post(new EBSkip(DownloadManagerActivity.TAG, DownloadManagerActivity.INDEX_DOWNLOAD)); - } else { - Intent downloadIntent = DownloadManagerActivity.getDownloadMangerIntent(context, null, ENTRANCE_DOWNLOAD); - downloadIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(downloadIntent); - } - - - } else { - // 助手未在运行 - Bundle bundle = new Bundle(); - bundle.putString(KEY_TO, DownloadManagerActivity.TAG); - intent.putExtra(KEY_ENTRANCE, ENTRANCE_DOWNLOAD); - context.startActivity(SplashScreenActivity.getSplashScreenIntent(context, bundle)); - } + DirectUtils.directToDownloadManager(context, ENTRANCE_DOWNLOAD); } - } diff --git a/app/src/main/java/com/halo/assistant/HaloApp.java b/app/src/main/java/com/halo/assistant/HaloApp.java index 4be878187e..2abe9b310d 100644 --- a/app/src/main/java/com/halo/assistant/HaloApp.java +++ b/app/src/main/java/com/halo/assistant/HaloApp.java @@ -193,6 +193,7 @@ public class HaloApp extends TinkerAppLike { }); } + // todo 动态注册和静态注册并行的话会触发多次回调 // 3.5 开始将 targetSdk 升级至 26,原来写在 Manifest 的部分 receiver 由于系统限制需要换成在运行时注册 private void initReceiver() { DownloadReceiver downloadReceiver = new DownloadReceiver();