2016-05-18 19 views
0

を隠していない私はそう、私はヘッドアップ進行中の通知を作成した通知の引き出しからキャンセルできないだろうヘッドアップ通知が必要になります。ヘッズアップの継続的な通知

NotificationCompat.Builder mBuilder = 
      new NotificationCompat.Builder(context) 
        .setSmallIcon(R.drawable.logo_notification) 
        .setContentTitle("Title") 
        .setPriority(NotificationCompat.PRIORITY_HIGH) 
        .setDefaults(Notification.DEFAULT_ALL) 
        .setGroup(KEY) 
        .setGroupSummary(true) 
        .setOngoing(true) 
        .setColor(context.getResources().getColor(R.color.tab_indicator_color)); 


    // Creates an explicit intent for an Activity in your app 
    Intent resultIntent = new Intent(context, Activity.class); 

    // The stack builder object will contain an artificial back stack for the 
    // started Activity. 
    // This ensures that navigating backward from the Activity leads out of 
    // your application to the Home screen. 
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); 
    // Adds the back stack for the Intent (but not the Intent itself) 
    stackBuilder.addParentStack(WActivity.class); 
    // Adds the Intent that starts the Activity to the top of the stack 
    stackBuilder.addNextIntent(resultIntent); 
    PendingIntent resultPendingIntent = 
      stackBuilder.getPendingIntent(
        0, 
        PendingIntent.FLAG_UPDATE_CURRENT 
      ); 
    mBuilder.setContentIntent(resultPendingIntent); 

    NotificationManager mNotificationManager = 
      (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 

    Intent pIntent = new Intent(context, PService.class); 
    pIntent.setAction("ACTION"); 
    PendingIntent piPause = PendingIntent.getService(context, NOTIFICATION_ID, pIntent, 0); 
    mBuilder.addAction(icon, title, piPause); 

    Intent sIntent = new Intent(context, SService.class); 
    sIntent.setAction("ACTION"); 
    PendingIntent piDismiss = PendingIntent.getService(context, NOTIFICATION_ID, sIntent, 0); 
    mBuilder.addAction(icon2, title2, piDismiss); 

問題が通知した後、トップに表示されていることですそれは通知ドロワに隠れません。しかし通知が進行中でなければ、それは隠れます。通知引き出しに隠れるような見出しの通知が必要です。

+0

「setOngoing」は使用しないでください。通知はしばらくすると自動的に非表示になります。 – Swayam

答えて

0

AFAIKの通知では、ヘッズアップ通知として表示するように設定する必要があります。

.setPriority(NotificationCompat.PRIORITY_HIGH) 
.setDefaults(Notification.DEFAULT_ALL) 

setOngoing()通知が進行中であり、使用者によって非表示にすることができないことを意味します。おそらくあなたの通知は一番上にあり、隠れていないのではないかと思います。 setOngoing(true)を削除し、にする必要があります。

+0

しかし、通知リスト(通知ドロワ)からキャンセルできない通知が必要ですが、数秒後には画面の上から隠れることになります。 – sofi37

+0

これには、これらのフラグを使用することができます。 'mNotification.flags | = Notification.FLAG_NO_CLEAR |通知.FLAG_ONGOING_EVENT; ' – Swayam

+0

私はそれを試しましたが、通知はまだ画面の一番上にあり、通知リストには非表示になっています – sofi37

関連する問題