ven*_*lav 3 java notifications android
这里的android很新:)
我有一个通知构建器,如果应用程序目标版本大于4.0,则没有问题.但是当我切换到2.3时,我在此行上收到错误消息"Notificaiton.Builder无法解析为类型".
Notification notification = new Notification.Builder(this)
.setSmallIcon(drawable_small)
.setLargeIcon(drawable_big)
.setWhen(System.currentTimeMillis()).setTicker(content_title)
.setContentTitle(content_title).setContentInfo(content_info)
.setContentText(content_text).setContentIntent(pIntent)
.getNotification();
Run Code Online (Sandbox Code Playgroud)
这个问题现在解决了!但是我现在有另一个它它在每个R(资源)上给我一个错误,我可以选择导入R.如果我导入它,它会给我每个资源的错误.
setContentView(R.layout.activity_main);
Run Code Online (Sandbox Code Playgroud)
实现你的Notification喜欢
Notification noti = new NotificationCompat.Builder(context)
.setSmallIcon(icon_small)
.setTicker(message)
.setLargeIcon(largeIcon)
.setWhen(System.currentTimeMillis())
.setContentTitle(title)
.setContentText(message)
.setContentIntent(contentIntent)
//At most three action buttons can be added
.setAutoCancel(true).build();
Run Code Online (Sandbox Code Playgroud)
并将支持库v4添加到项目中并导入
import android.support.v4.app.NotificationCompat;
Run Code Online (Sandbox Code Playgroud)
NotificationCompat帮助用于以向后兼容的方式访问Notification之后引入的功能.API level 4
有关更多信息,请访问:http://developer.android.com/guide/topics/ui/notifiers/notifications.html
| 归档时间: |
|
| 查看次数: |
2913 次 |
| 最近记录: |