From f690cf0b627b7136eccd7f903ed27b449231e7f2 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Wed, 21 Dec 2022 16:01:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DAPP=E5=88=9A=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E8=BF=98=E6=B2=A1=E7=94=A8=E5=88=9B=E5=BB=BAActivity?= =?UTF-8?q?=E6=97=B6=E5=8F=97=E5=88=B0=E6=8E=A8=E9=80=81=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=B9=B6=E8=AF=95=E5=9B=BE=E5=BC=B9=E5=87=BA=E6=9D=83=E9=99=90?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=AF=B9=E8=AF=9D=E6=A1=86=E6=97=B6=EF=BC=8C?= =?UTF-8?q?context=E4=B8=BA=E7=A9=BA=E5=AF=BC=E8=87=B4=E7=9A=84=E9=97=AA?= =?UTF-8?q?=E9=80=80=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/CustomMessageReceiver.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) 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) {