我在Play商店有一个应用程序,最近我收到很多关于ActivityThread.java的崩溃消息
致命异常
致命异常:android.app.RemoteServiceException 从包XXX发布的错误通知:无法展开RemoteViews:StatusBarNotification(pkg = XXX user = UserHandle {0} id = 1 tag = null score = 0:Notification(pri = 0 contentView = XXX / 0x1090065 vibrate = null sound = null defaults = 0x0 flags = 0x0 kind = [null]))
alarmNotificationManager = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, MainActivity.class), 0);
NotificationCompat.Builder alamNotificationBuilder = new NotificationCompat.Builder(
this,"1").setContentTitle("Prayer Time Alert!").setSmallIcon(R.mipmap.icon_logo)
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setDeleteIntent(createOnDismissedIntent(this,1))
.setContentText(msg);
alamNotificationBuilder.setContentIntent(contentIntent);
alarmNotificationManager.notify(1, alamNotificationBuilder.build());
private PendingIntent createOnDismissedIntent(Context context, int notificationId) {
Intent intent = new Intent(context, NotificationDismissedReceiver.class);
intent.putExtra("com.my.app.notificationId", notificationId);
PendingIntent pendingIntent =
PendingIntent.getBroadcast(context.getApplicationContext(),
notificationId, intent, 0);
return pendingIntent;
}
public class NotificationDismissedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
int notificationId = intent.getExtras().getInt("com.my.app.notificationId");
/* Your code to handle the event here */
if (Global.mPlayer != null) {
Global.mPlayer.stop();
}
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
manager.cancel(notificationId);
}
}
答案 0 :(得分:0)
将此更改为 - :
alarmNotificationManager.notify(1, alamNotificationBuilder.build());
要 - :
alarmNotificationManager.notify(0, alamNotificationBuilder.build());
id应与待处理意图和通知管理器中的ID相同。