Android 来自广播接收器的通知挂起内容
伙计们 我已经调试了好几天了,但是我找不到答案 正如标题所说,我正在使用Android 来自广播接收器的通知挂起内容,android,android-intent,android-notifications,android-pendingintent,Android,Android Intent,Android Notifications,Android Pendingintent,伙计们 我已经调试了好几天了,但是我找不到答案 正如标题所说,我正在使用BroadcastReceiver发出通知 在我添加.addAction之前,一切都很好 它需要pendingent作为默认设置,我做了一个pendingent 但问题是,;当我添加.addAction时,它会这样说 Incompatiable types. Required : android.app.Notification Found : android.app.Notification.Builder 代码在没
BroadcastReceiver
发出通知
在我添加.addAction
之前,一切都很好
它需要pendingent
作为默认设置,我做了一个pendingent
但问题是,;当我添加.addAction
时,它会这样说
Incompatiable types.
Required : android.app.Notification
Found : android.app.Notification.Builder
代码在没有.addAction
和PendingContent
的情况下运行良好
有什么问题吗
这是我的密码
,BroadcastReceiver
WifiService.java
Intent intent = new Intent(mcontext, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pIntent = PendingIntent.getActivity(mcontext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); Notification noti = new Notification.Builder(mcontext) .setContentTitle("Welcome home!") .setContentText("You have a to-do; " + hometodo) .setSmallIcon(R.drawable.home_light) .setLargeIcon(icon) .setLights(0xFFFFD800, 5000, 0) .addAction(R.drawable.archive_notification, "Mark as done", pIntent); //.addAction gets the error. .build(); NotificationManager notificationManager = (NotificationManager) mcontext.getSystemService(mcontext.NOTIFICATION_SERVICE); notificationManager.notify(0, noti);
通知compat
设置。添加操作(…)
检查
在Android 4.1之前的平台上不会出现操作按钮。行动
按钮依赖于扩展通知,这些通知仅在中可用
Android 4.1及更高版本
.addAction(R.drawable.archive\u通知,“标记为完成”,pIntent)代码>删除我觉得自己好笨;(谢谢..没问题,你的welcome@BedrockDev只需删除多余的;
@pskink ya你真的有一只鹰眼
。谢谢