2015-11-02 216 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