Notification Icon vom Foreground Service ändern

GMoN

GMoN

Dauergast
394
Wie kann man denn z.B. das Notification Icon vom Service ändern, wenn er schon läuft? läßt sich das dann überhaupt noch ändern? Denn ich kann diese Notification ja auch nicht canceln, solange er noch läuft. Ich würde aber gerne zur Laufzeit bei bestimmten Ereignissen die Farbe des Icons ändern.


Code:
private void showNotification() {
        
        CharSequence text = "G-MoN scanning is activ";
        
        Notification notification = new Notification(R.drawable.service1, text,
                System.currentTimeMillis());

        
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                new Intent(this, de.carknue.gmon2.gmon.class), 0);

        notification.setLatestEventInfo(this, "G-Mon", text, contentIntent);
        notification.flags |= Notification.FLAG_ONGOING_EVENT;

        
        startForeground(0x7f0a0036,notification);
     
    }
 
Hallo,

schau mal hier !

Dort steht unter Punkt 2. Instantiate the Notification:

Code:
int icon = R.drawable.notification_icon;
CharSequence tickerText = "Hello";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);

Meinst Du das? Kannst Du damit was anfangen?

Gruß Bobert
 
Hallo,
weiß zufällig jemand, wie man externe Icons in einer App so einbinden kann, daß sie in der Notification Bar angezeigt werden? Konkret geht es darum, daß für eine Profile-App der User sich beliebige Icons für die jeweiligen Profile suchen kann, die dann auch korrekt im Widget angezeigt werden, jedoch nicht in der Notification Bar. Das Problem ist wohl
int icon = R.drawable.notification_icon;
wobei nur interne Icons eine Resource ID besitzen, externe jedoch nicht. Ich bin nicht der Entwickler der App, versuche nur zu helfen da er nicht deutschsprachig ist.
Habt Ihr eine Idee?
Gruß,
Gabs
 

Ähnliche Themen

D
Antworten
14
Aufrufe
1.699
chrs267
chrs267
C
  • Chicken Wing
Antworten
4
Aufrufe
842
Chicken Wing
C
Vapeilas91
  • Vapeilas91
Antworten
3
Aufrufe
696
swa00
swa00
Zurück
Oben Unten