修复APP刚启动还没用创建Activity时受到推送通知并试图弹出权限申请对话框时,context为空导致的闪退问题
This commit is contained in:
parent
af5d8dbf19
commit
f690cf0b62
@ -89,20 +89,23 @@ public class CustomMessageReceiver extends PushMessageReceiver {
|
|||||||
public boolean onNotificationMessageArrived(Context context, PushType pushType, PushNotificationMessage notificationMessage) {
|
public boolean onNotificationMessageArrived(Context context, PushType pushType, PushNotificationMessage notificationMessage) {
|
||||||
Log.i("gmc", notificationMessage.getPushContent() + "VVV" + notificationMessage.getPushTitle() + "gmc11112222" + notificationMessage.getExtra());
|
Log.i("gmc", notificationMessage.getPushContent() + "VVV" + notificationMessage.getPushTitle() + "gmc11112222" + notificationMessage.getExtra());
|
||||||
if (!SpUtil.getInstance().getBooleanValue("NOTIFICATION")) {
|
if (!SpUtil.getInstance().getBooleanValue("NOTIFICATION")) {
|
||||||
Activity activity = AppContext.activityWeakReference.get();
|
if (AppContext.activityWeakReference != null) {
|
||||||
if (activity != null) {
|
Activity activity = AppContext.activityWeakReference.get();
|
||||||
DialogUitl.showSimpleDialog(activity, "应用需要通知权限", new DialogUitl.SimpleCallback() {
|
if (activity != null) {
|
||||||
@Override
|
DialogUitl.showSimpleDialog(activity, "应用需要通知权限", new DialogUitl.SimpleCallback() {
|
||||||
public void onConfirmClick(Dialog dialog, String content) {
|
@Override
|
||||||
Intent intent = new Intent();
|
public void onConfirmClick(Dialog dialog, String content) {
|
||||||
intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
|
Intent intent = new Intent();
|
||||||
intent.putExtra("app_package", context.getPackageName());
|
intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
|
||||||
intent.putExtra("app_uid", context.getApplicationInfo().uid);
|
intent.putExtra("app_package", context.getPackageName());
|
||||||
// for Android 8 and above
|
intent.putExtra("app_uid", context.getApplicationInfo().uid);
|
||||||
intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName());
|
// for Android 8 and above
|
||||||
activity.startActivity(intent);
|
intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName());
|
||||||
}
|
activity.startActivity(intent);
|
||||||
});
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (notificationMessage.getExtra() == null) {
|
if (notificationMessage.getExtra() == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user