我有我的自定义通知:
Intent myIntent = new Intent(this, MainActivity.class);
PendingIntent myPendingIntent = PendingIntent.getActivity(this, 0, myIntent, 0);
// build notification
// the addAction re-use the same myIntent to keep the example short
Notification myNotification = new Notification.Builder(this)
.setContentTitle("My App")
.setContentText("Service is not running")
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(myPendingIntent)
.setAutoCancel(true)
.addAction(R.drawable.ic_action_mic, "Start Service", myPendingIntent).build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, myNotification);
我只是在问我应该把 onClickListener 放在哪里生成的按钮.addAction()
?