尝试修复下载通知跳转问题 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/824 (2)
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -193,6 +193,7 @@ public class HaloApp extends TinkerAppLike {
|
||||
});
|
||||
}
|
||||
|
||||
// todo 动态注册和静态注册并行的话会触发多次回调
|
||||
// 3.5 开始将 targetSdk 升级至 26,原来写在 Manifest 的部分 receiver 由于系统限制需要换成在运行时注册
|
||||
private void initReceiver() {
|
||||
DownloadReceiver downloadReceiver = new DownloadReceiver();
|
||||
|
||||
Reference in New Issue
Block a user