【发布时间】:2016-12-24 11:01:35
【问题描述】:
我知道您可以使用 PendingIntents 从操作按钮启动活动。当用户单击通知操作按钮时,如何实现调用 a 方法?
public static void createNotif(Context context){
...
drivingNotifBldr = (NotificationCompat.Builder) new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.steeringwheel)
.setContentTitle("NoTextZone")
.setContentText("Driving mode it ON!")
//Using this action button I would like to call logTest
.addAction(R.drawable.smallmanwalking, "Turn OFF driving mode", null)
.setOngoing(true);
...
}
public static void logTest(){
Log.d("Action Button", "Action Button Worked!");
}
【问题讨论】:
标签: android android-layout android-notifications action-button