【问题标题】:Changing Notifications on android code to use notification.builder更改 Android 代码上的通知以使用 notification.builder
【发布时间】:2015-03-15 12:19:47
【问题描述】:

我不是开发人员,我正在努力让一些示例代码运行良好。 我运行的 API 与我正在使用的代码不是 100% 兼容。(API15)。

谁能帮我重新格式化这段代码以使用更新的样式builder notifications

(我试过了,但根据链接的问题无法找到正确的方法)

{           
    Notification notification = new Notification(R.drawable.ic_launcher, "Robot service running", System.currentTimeMillis());
    notification.setLatestEventInfo(this, "Robot Service", "Click to stop", PendingIntent.getService(this, 0, new Intent("stop", null, this, this.getClass()), 0));
    notification.flags |= Notification.FLAG_ONGOING_EVENT;
    nm.notify(0, notification);     
}

【问题讨论】:

    标签: java android notifications


    【解决方案1】:
    Notification noti = new Notification.Builder(mContext)
             .setContentTitle("New mail from " + sender.toString())
             .setContentText(subject)
             .setSmallIcon(R.drawable.new_mail)
             .setLargeIcon(aBitmap)
             .build();
    

    更多详情请使用以下链接:

    http://developer.android.com/reference/android/app/Notification.Builder.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多