通过PendingIntent

时间:2016-04-23 09:05:05

标签: android service notifications android-pendingintent

我想通过点击通知中的操作来关闭服务。似乎唯一的方法就是使用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());

0 个答案:

没有答案