0
任何人都可以告訴我如何在點擊通知後立即觸發廣播!如果我得到一些關於相同的教程,那將會很棒。在android中使用推送通知的觸發廣播回收器
任何人都可以告訴我如何在點擊通知後立即觸發廣播!如果我得到一些關於相同的教程,那將會很棒。在android中使用推送通知的觸發廣播回收器
論的onMessage擴展GCMBaseIntentService類()調用setNotificationMethod如下
private void setNotification(int defaults, String message, int flag) {
NotificationManager mNotificationManager;
int MOOD_NOTIFICATIONS = 12345;
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// This method sets the defaults on the notification before posting it.
Intent handleNotification = new Intent(this, PushNotifier.class);
handleNotification.putExtra("Result", resultfrmServer);
// This is who should be launched if the user selects our notification.
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
handleNotification, PendingIntent.FLAG_UPDATE_CURRENT);
final Notification notification = new Notification(
R.drawable.ic_launcher, // the icon for the status bar
message, // the text to display in the ticker
System.currentTimeMillis()); // the timestamp for the
// notification
notification.setLatestEventInfo(this, // the context to use
getText(R.string.app_name),
// the title for the notification
message, // the details to display in the notification
contentIntent); // the contentIntent (see above)
notification.defaults = defaults;
notification.flags = flag;
mNotificationManager.notify(MOOD_NOTIFICATIONS,notification);
}
現在,當該通知被點擊PushNotifier開始授課。在這裏,您可以決定是否要啓動其他活動或註冊廣播接收器。此外,如果您需要pushnotification中收到的信息,您可以使用掛起的意圖和用戶相應地將其發送到pushNotifier類。