【问题标题】:StartForeground Bad notification Android 2.3.XStartForeground 坏通知 Android 2.3.X
【发布时间】:2013-09-04 08:58:37
【问题描述】:

我有一个错误报告,对于一些 2.3.X 版本的 android 设备:

android.app.RemoteServiceException:startForeground 的错误通知:java.lang.IllegalArgumentException

这是我的方法...

final static int myID = 6785674;

public void putServiceToForeground() {
    if (notif == null) {
        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(MyApp.getAppContext())
        .setContentTitle("");
        notif = mBuilder.build();
        notif.icon = R.drawable.pixel;
    }
    startForeground(myID, notif);
}

【问题讨论】:

    标签: android service android-notifications foreground


    【解决方案1】:

    使用生成器设置图标并仔细检查documentation

    需要的通知内容

    通知对象必须包含以下内容:

    • 一个小图标,由 setSmallIcon() 设置
    • 标题,由 setContentTitle() 设置
    • 详细文本,由 setContentText() 设置

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-23
      • 2019-08-28
      相关资源
      最近更新 更多