2016-12-31 8 views
0

通知をクリックしたときにアクティビティを開始するにはどうすればよいですか?私は意図を挿入しようとしているが、代わりにNotificationCompat.Builderを使用し、Notification.Builderを使用しないでくださいanything-通知でアクティビティを開始する

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

答えて

1

を行っていません。あなたのビルダーで

Intent intent = new Intent(this, NewActivity.class); 

PendingIntent pendingIntent = 
    PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); 

そして:

mBuilder.setContentIntent(pendingIntent); 
+0

は、すべてのAPIレベルはい、それが必要 –

+0

にこの作業を行います。 – GVillani82

関連する問題