修复APP刚启动还没用创建Activity时受到推送通知并试图弹出权限申请对话框时,context为空导致的闪退问题
This commit is contained in:
parent
af5d8dbf19
commit
f690cf0b62
@ -89,6 +89,7 @@ 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")) {
|
||||||
|
if (AppContext.activityWeakReference != null) {
|
||||||
Activity activity = AppContext.activityWeakReference.get();
|
Activity activity = AppContext.activityWeakReference.get();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
DialogUitl.showSimpleDialog(activity, "应用需要通知权限", new DialogUitl.SimpleCallback() {
|
DialogUitl.showSimpleDialog(activity, "应用需要通知权限", new DialogUitl.SimpleCallback() {
|
||||||
@ -101,10 +102,12 @@ public class CustomMessageReceiver extends PushMessageReceiver {
|
|||||||
// for Android 8 and above
|
// for Android 8 and above
|
||||||
intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName());
|
intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName());
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (notificationMessage.getExtra() == null) {
|
if (notificationMessage.getExtra() == null) {
|
||||||
msg.setImg("" + notificationMessage.getSenderPortrait());
|
msg.setImg("" + notificationMessage.getSenderPortrait());
|
||||||
msg.setTitle(notificationMessage.getPushTitle());
|
msg.setTitle(notificationMessage.getPushTitle());
|
||||||
|
Loading…
Reference in New Issue
Block a user