2016-10-04 3 views
1

Ich habe eine Benachrichtigung, die ich immer an der Spitze bleiben möchte.Wie man eine Benachrichtigung macht, bleibt an der Spitze?

Ich habe bereits eine Priorität von 2

gegeben Meist bleibt es an der Spitze aber an, dass es ein offenes WiFi-Netzwerk ist, dann nach unten meiner Meldung geht und die Benachrichtigung über offenes WiFi-Netzwerk kommt auf der Oberseite Position.

Aber wenn ich auf die Benachrichtigung von vlc (für Android) einen Song bezahlen sah, bleiben die Benachrichtigungen von vlc an der Spitze und die Benachrichtigung von offenen WiFi-Netzwerk geht nach unten.

I Meldung ist noch nicht abgeschlossen und mit Priorität 2.

Was soll ich tun. Ich bin ein Anfänger also bitte bitte mit mir.

Und danke im Voraus.

+0

VLC zeigt eine laufende Benachrichtigung. – StenSoft

+0

hast du gesetzt .setPriority (Notification.PRIORITY_MAX); ? –

+0

Nun ja, aber ich habe es gegeben max. numerischer Wert. d. h. 2 als Priorität. Und ja, meine Demütigungen sind ebenfalls im Gange. –

Antwort

2

haben Sie diese

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

Prioritätsstufen versucht ->PRIORITY_MAX/PRIORITY_HIGH/PRIORITY_DEFAULT/PRIORITY_LOW/PRIORITY_MIN

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

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

und als Sten Weiche sagte Android: How to create an "Ongoing" notification?

+0

Ja, ich habe es schon ausprobiert. –

0

Ich glaube, Sie an diesem Code verweisen können:

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

Nun, meiner Meinung nach ist die maximale Priorität 2 und ich habe es bereits gegeben. –

Verwandte Themen