2016-12-31 33 views
1

默認通知點擊行爲正在執行活動,但我想顯示敬酒或調用方法。我怎麼做?如何讓我的通知執行操作onclick?

//**cleareble notification**// 
NotificationManager notificationManager = (NotificationManager) this 
      .getSystemService(Context.NOTIFICATION_SERVICE); 
    Notification noti = new NotificationCompat.Builder(this) 
      .setAutoCancel(true) 
      .setContentIntent(
        PendingIntent.getActivity(this, 0, getIntent(), 
          PendingIntent.FLAG_UPDATE_CURRENT)) 
      .setContentTitle("HELLO world") 
      .setContentText("PLEASE CHECK WE HAVE UPDATED NEWS") 
      .setDefaults(Notification.DEFAULT_ALL) 
      .setSmallIcon(R.drawable.ic_launcher) 
      .setTicker("ticker message") 
      .setWhen(System.currentTimeMillis()).build(); 
    //noti.flags |= Notification.FLAG_NO_CLEAR; 
    notificationManager.notify(0, noti); 
+0

您需要的活動,以顯示你的吐司 – 2016-12-31 18:00:21

+0

我該如何推出一些其他活動,而不是主? –

+0

[Here](http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/)是Firebase上的一個很好的教程。 –

回答

1

看看在Android developper網站Building a Notification

此鏈接基本上你創建的PendingIntent和使用您的Notification.Builder的setContentIntent方法。

一下第定義通知的行動設置通知的點擊行爲

+0

你試過這個嗎? – 2016-12-31 18:57:15