2016-10-04 52 views
1

我有一個通知,我總是想留在上面。如何讓通知保持在最前?

我已經給它的2

優先級主要是它停留在上面,但是,假設有一個開放的WiFi網絡,然後我通知下山和開放的WiFi網絡的通知來自頂部位置。

但是,當我查看付費歌曲的vlc(Android版)通知時,vlc的通知保持在最高,並且開放WiFi網絡的通知關閉。

我的通知正在進行中,優先級爲2.

我該怎麼做。我是初學者,請耐心等待。

並提前致謝。

+0

VLC顯示正在進行的通知。 – StenSoft

+0

是否設置了.setPriority(Notification.PRIORITY_MAX); ? –

+0

嗯,是的,但我已經給它最大。數值。即2作爲優先事項。是的,我的恥辱也在進行中。 –

回答

2

你嘗試過這個

NotificationCompat.Builder builder = 
      (NotificationCompat.Builder) new NotificationCompat.Builder(context) 
      .setSmallIcon(R.drawable.notify_icon) 
      .setContentTitle("Notification") 
      .setContentText("ON Top") 
      .setPriority(Notification.PRIORITY_MAX); 

優先等級 - >PRIORITY_MAX/PRIORITY_HIGH/PRIORITY_DEFAULT/PRIORITY_LOW/PRIORITY_MIN

閱讀 https://material.google.com/patterns/notifications.html#correctly_set_and_manage_notification_priority

https://developer.android.com/reference/android/app/Notification.html#priority

和斯登軟說 Android: How to create an "Ongoing" notification?

+0

是的,我已經試過了。 –

0

我覺得你可以參考下面的代碼:

Intent push = new Intent(); 
    push.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    push.setClass(this, NotificationDemo.class); 
    PendingIntent pi = PendingIntent.getActivity(this, 0, push, PendingIntent.FLAG_CANCEL_CURRENT); 

    NotificationManager nm=(NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE); 

    Notification updateNotification = new Notification.Builder(this) 
      .setSmallIcon(R.drawable.ic_face_black_24dp) 
      .setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.mipmap.ic_launcher)) 
      .setContentTitle("Priority Max Notification Title") 
      .setContentText("Priority Max Notification Message") 
      .setAutoCancel(false) 
      .setDefaults(Notification.DEFAULT_SOUND) 
      .setPriority(Notification.PRIORITY_MAX) 
      .setFullScreenIntent(pi,true) 
      .build(); 



    nm.notify("priorityMaxTest",2,updateNotification); 
+0

那麼,根據我最大的優先級是2,我已經給了它。 –