diff --git a/app/src/main/java/com/shayu/phonelive/utils/CustomMessageReceiver.java b/app/src/main/java/com/shayu/phonelive/utils/CustomMessageReceiver.java index 844c12b45..ad6efe52e 100644 --- a/app/src/main/java/com/shayu/phonelive/utils/CustomMessageReceiver.java +++ b/app/src/main/java/com/shayu/phonelive/utils/CustomMessageReceiver.java @@ -89,20 +89,23 @@ public class CustomMessageReceiver extends PushMessageReceiver { public boolean onNotificationMessageArrived(Context context, PushType pushType, PushNotificationMessage notificationMessage) { Log.i("gmc", notificationMessage.getPushContent() + "VVV" + notificationMessage.getPushTitle() + "gmc11112222" + notificationMessage.getExtra()); if (!SpUtil.getInstance().getBooleanValue("NOTIFICATION")) { - Activity activity = AppContext.activityWeakReference.get(); - if (activity != null) { - DialogUitl.showSimpleDialog(activity, "应用需要通知权限", new DialogUitl.SimpleCallback() { - @Override - public void onConfirmClick(Dialog dialog, String content) { - Intent intent = new Intent(); - intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS"); - intent.putExtra("app_package", context.getPackageName()); - intent.putExtra("app_uid", context.getApplicationInfo().uid); - // for Android 8 and above - intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName()); - activity.startActivity(intent); - } - }); + if (AppContext.activityWeakReference != null) { + Activity activity = AppContext.activityWeakReference.get(); + if (activity != null) { + DialogUitl.showSimpleDialog(activity, "应用需要通知权限", new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + Intent intent = new Intent(); + intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS"); + intent.putExtra("app_package", context.getPackageName()); + intent.putExtra("app_uid", context.getApplicationInfo().uid); + // for Android 8 and above + intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName()); + activity.startActivity(intent); + + } + }); + } } } if (notificationMessage.getExtra() == null) {