因此,我的应用程序始终完美运行,但有时会显示此错误 从com.myapp包发布的错误通知:无法扩展RemoteViews:StatusBarNotification
Intent intentRadar = new Intent(this, RadarActivity.class);
intentRadar.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, (int)System.currentTimeMillis(), intentRadar, 0);
//Intent to close app
Intent intentClose = new Intent(this, CloseAppReceiver.class);
PendingIntent closeIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intentClose,0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setTicker(getResources().getString(R.string.titulo_app_executando));
builder.setContentTitle(getString(R.string.titulo_app_executando));
builder.setContentText(getString(R.string.msg_app_run));
builder.setSmallIcon(R.drawable.ic_notification);
builder.setContentIntent(pendingIntent);//Seta a intent do radar para voltar
builder.setOngoing(true);
//action off app
builder.addAction(R.drawable.turn_off, getResources().getString(R.string.off_app), closeIntent);
builder.setWhen(0);
builder.setPriority(Notification.PRIORITY_MAX);
notificationAppRun = builder.build();
nm.notify(R.drawable.ic_notification,notificationAppRun);//show notification
答案 0 :(得分:0)
为什么不使用remoteView?
nm.notify(R.drawable.ic_notification, notificationAppRun); //show notification
我认为第一个参数是错误的。你需要在这里设置一个id,而不是drawable id