修复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) {
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user