2017-10-29 13 views
1

通知をクリックすると自分自身と同じ操作ボタンが表示されますが、それらを区別したい、ボタンを何かしたいときにクリックすると通知はここaddActionsetContentIntentに私のコード -通知のクリックと通知ボタンを区別する方法

Intent intent = new Intent(this, NotificationView.class); 
    PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 
      PendingIntent.FLAG_UPDATE_CURRENT); 

    NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(this) 
      .setSmallIcon(R.mipmap.ic_launcher) 
      .setTicker(getString(R.string.notificationticker)) 
      .setContentTitle(getString(R.string.notificationtitle)) 
      .setContentText(yeah) 
      .addAction(R.drawable.ic_favorite, getString(R.string.azor), pIntent) 
      .setContentIntent(pIntent) 
      .setAutoCancel(true); 

    NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
    notificationmanager.notify(0, builder.build()); 

答えて

1

峠異なるPendingIntentsで、他の自己ものです。
現在、両方とも同じものを使用しています。pIntentインスタンスです。

両方とも同じアクティビティを起動したいが異なるものを実行したい場合は、保留中のインテントを作成するために使用されたインテントに余分なものを追加できます。

+0

ありがとうございます! –

関連する問題