2015-11-02 233 views

回答

2

您可以通过两种方式启动的通知点击服务:

1)第一种方式:您可以拨打广播接收器,当用户点击的通知。

为此,您需要使用PendingIntent.getBroadcast而不是 getActivity()。

参考:How to Start one Activity and two service on notification click

2)第二种方式:您可以直接当用户点击通知启动服务。

为此,您需要使用PendingIntent.getService而不是 getActivity()。

参考:Start Service from Notification

+0

我不想在通知点击启动服务。我需要听已经运行的服务中的通知点击 – Dhakchianandan

+0

@Dhakchianandan:http://stackoverflow.com/questions/22252065/refreshing-activity-on-receiving-gcm-push-notification – KishuDroid