我想通过点击通知中的操作来关闭服务。似乎唯一的方法就是使用PendingIntent。但我的问题是我如何通过未决意图关闭服务?我是否必须开始广播或其他服务来关闭第一个或者是否有其他方式?
Intent intent1 = new Intent(this, Downloader.class);
PendingIntent pi1 =PendingIntent.getService(this,i,intent1,0) ;
mBuilder..addAction(R.drawable.ic_stat_name, "close",pi1);
mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mBuilder.setOngoing(true);
mNotificationManager.notify(i, mBuilder.build());