我知道你可以使用PendingIntents从操作按钮启动Activity。如何使得当用户点击通知操作按钮时调用某个方法?
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!");
}
intentAction
传递给了addAction
。难道不应该是pIntentlogin
吗? - Faizan SyedcreateNotif
方法的this
对象? - Donald Duck