【问题标题】:Sometimes this happens Couldn't expand RemoteViews for: StatusBarNotification有时会发生这种情况无法扩展 RemoteViews:StatusBarNotification
【发布时间】:2017-04-12 12:52:43
【问题描述】:

所以,我的应用程序始终运行良好,但有时会显示此错误 从包 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

【问题讨论】:

  • 我遇到了同样的问题。你找到解决办法了吗?

标签: android


【解决方案1】:

你为什么不用remoteView?

nm.notify(R.drawable.ic_notification, notificationAppRun); //show notification

我认为第一个参数是错误的。你需要在这里设置一个id,而不是drawable id

【讨论】:

    猜你喜欢
    • 2012-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-19
    • 2021-01-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多