guys。來自BroadcastReceiver的Notification PendingIntent
我一直在調試這幾天,但我找不到這個答案。
正如標題所示,我使用BroadcastReceiver
來通知我。
一切都很好,直到我加入.addAction
。
默認需要PendingIntent
,我做了PendingIntent
。
但問題是這樣的;當我添加.addAction
,它說這
Incompatiable types.
Required : android.app.Notification
Found : android.app.Notification.Builder
的代碼,是用了.addAction
和PendingIntent
完美的罰款。
可能是什麼問題?
這裏是我的代碼,
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);
'.addAction(R.drawable.archive_notification, 「標記爲已完成」,pIntent);''刪除;' – pskink
我覺得很愚蠢;(感謝.. –
沒有概率,你的歡迎 – pskink