我点击按钮后尝试关闭我的应用程序。
我知道我需要使用待定意图并且意图这样做,但我不知道我该怎么做以及我可以使用哪些标记或动作。
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "")
.setSmallIcon(R.mipmap.ic_launcher_notification)
.setContentTitle("Close your app")
.setContentText("Your app is still running...")
.addAction(R.drawable.ic_exit,"Close App",
PendingIntent.getBroadcast(this, 0, intent, 0))
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(0, builder.build());
这不起作用......