Notification wird nicht angezeigt wenn App nicht offen ist.

jabaduu

Bekanntes Mitglied
Moin, ich habe die folgenden beiden Methoden um eine Notification zu erzeugen, es funktioniert auch,
nur ist mir aufgefallen, dass es nur funktioniert wenn man die App geöffnet hat. Aber die Notification soll ja erscheinen, wenn man die App
nicht gestartet hat.
Kann mir hier jemand weiterhelfen?

Java:
public void displayNotification(String text){
    createNotificationChannel();
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID);
    builder.setSmallIcon(R.drawable.ic_list_notification);
    builder.setContentTitle("New Item");
    builder.setContentText(text);
    builder.setPriority(NotificationCompat.PRIORITY_DEFAULT);
    NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this);
    notificationManagerCompat.notify(NOTIFICATION_ID,builder.build());
}

private void createNotificationChannel(){
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        CharSequence name = "Notifications";
        String description = "my notifications";
        int importance = NotificationManager.IMPORTANCE_DEFAULT;
        NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, name,importance);
        notificationChannel.setDescription(description);
        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        notificationManager.createNotificationChannel(notificationChannel);
    }
}
 
Zuletzt bearbeitet von einem Moderator:
Ähnliche Java Themen
  Titel Forum Antworten Datum
L Android Sms Notification weiterleiten an PC Android & Cross-Platform Mobile Apps 9
S Notification mit Firebase Notification anpassen Android & Cross-Platform Mobile Apps 1
G Android Push Notification Android & Cross-Platform Mobile Apps 2
T Android Datenbankverbindung in Service für Push Notification Android & Cross-Platform Mobile Apps 0
M Notification nicht mehr senden nachdem sie geklickt wurde Android & Cross-Platform Mobile Apps 0
A Android Notification á la Skype Android & Cross-Platform Mobile Apps 1
G Activity-Wechsel bitte ohne Notification Android & Cross-Platform Mobile Apps 6
W Reward Ads AdMob wird nicht ausgeliefert. Android & Cross-Platform Mobile Apps 9
J Spinner wird nicht aktualisiert Android & Cross-Platform Mobile Apps 6
Naxon89 Duplicate class kotlin - und dies ohne das es angewendet wird Android & Cross-Platform Mobile Apps 1
ImageView wird nicht angezeigt Android & Cross-Platform Mobile Apps 4
W Bildschirm Nutzung Überwachen der App Nutzer ink. was angeklickt wird Android & Cross-Platform Mobile Apps 35
N XY-Plottet keine Daten obwohl Funktion ausgeführt wird Android & Cross-Platform Mobile Apps 4
K Null-Pointer-Exception in ListView - wird über Datenbank gefüllt Android & Cross-Platform Mobile Apps 1
R Android Do not disturb: Sound wird nicht abgespielt Android & Cross-Platform Mobile Apps 2
O Google Admob Ad wird nicht geladen und App stürzt ab Android & Cross-Platform Mobile Apps 1
M Paper DB wird in Android Studio nicht erkannt Android & Cross-Platform Mobile Apps 7
R Audio wird nur 1 Mal abgespielt Android & Cross-Platform Mobile Apps 2
A GraphView => X- und Y-Achse wird nicht angezeigt Android & Cross-Platform Mobile Apps 5
A jpg wird im Android Studio nicht akzeptiert Android & Cross-Platform Mobile Apps 3
Arif Android Radiobutton wird nicht deaktiviert Android & Cross-Platform Mobile Apps 1
Arif Android Canvas wird nicht gezeichnet? Android & Cross-Platform Mobile Apps 0
M TypedArray-Resource wird falsch geladen Android & Cross-Platform Mobile Apps 7
W Preview wird nicht korrekt angezeigt Android & Cross-Platform Mobile Apps 0
B Profilpic wird nach anmeldung nicht angezeigt. Android & Cross-Platform Mobile Apps 2
K Methode wird nicht gefunden Android & Cross-Platform Mobile Apps 1
J Kamera - Foto wird nicht gespeichert Android & Cross-Platform Mobile Apps 2
V Android Wird mein Vorhaben funktionieren? (Apk Datei decompilieren, bearbeiten, compilieren) Android & Cross-Platform Mobile Apps 2
G App wird nach Installation auf Smartphone beendet Android & Cross-Platform Mobile Apps 1
L Dialog anzeigen wenn auf Button gedrückt wird. Android & Cross-Platform Mobile Apps 4
S Android neue Version des Programms wird nicht in Emulator geladen Android & Cross-Platform Mobile Apps 1
O Android Switch Widget wird nicht angezeigt Android & Cross-Platform Mobile Apps 1
M Android ListView wird nicht dargestellt Android & Cross-Platform Mobile Apps 2
N PriceScannerApp: warum wird nach dem Scannen Display gleich schwarz? Android & Cross-Platform Mobile Apps 4
P Herausfinden, welches Fragment gerade angezeigt wird. Android & Cross-Platform Mobile Apps 1
M Android Nur erste Zeile wird vom Server empfangen Android & Cross-Platform Mobile Apps 0
A App wird bei start des Timers beendet Android & Cross-Platform Mobile Apps 1
A Wieso wird die App beendet ??? Android & Cross-Platform Mobile Apps 2
B Alle Daten gehen verloren, wenn die Displaysperre aktiviert wird? Android & Cross-Platform Mobile Apps 21
P trotz invalidate() wird onDraw() nicht aufgerufen Android & Cross-Platform Mobile Apps 15
W XML Layout: wann wird geladen? Android & Cross-Platform Mobile Apps 10
K Android Temperaturconverter, R.id.element wird nicht gefunden Android & Cross-Platform Mobile Apps 20
A onDraw wird nicht aufgerufen Android & Cross-Platform Mobile Apps 14
A Android Dialog wird nicht sofort angezeigt Android & Cross-Platform Mobile Apps 12
W ImageView wird nicht angezeigt Android & Cross-Platform Mobile Apps 19
T Android: ListView-Adapter: Adapter wird ständig aufgerufen Android & Cross-Platform Mobile Apps 2
F Android Datenbank upgrade wird nicht durchgeführt Android & Cross-Platform Mobile Apps 2
F Android R.raw wird nicht gefunden Android & Cross-Platform Mobile Apps 5
P ID wird nicht erzeugt Android & Cross-Platform Mobile Apps 2
C Problem Device/Emulator wird nicht erkannt Android & Cross-Platform Mobile Apps 3
R Zeichen-Codierung in (SMS) TextMessage, "_" wird § Android & Cross-Platform Mobile Apps 2
W MoveEvent reagiert nicht Game Android & Cross-Platform Mobile Apps 1
W Cookie Manger übermittelt nicht Android & Cross-Platform Mobile Apps 1
M PythonInterpreter funktioniert nicht richtig NoClassDefFoundError Android & Cross-Platform Mobile Apps 1
I Android SharedPreferences wenn App auf externem Speicher klappt nicht Android & Cross-Platform Mobile Apps 0
W Frisch generiertes Projekt Value nicht findbar NavController Drawer Android & Cross-Platform Mobile Apps 12
W WebView Linkvertise lädt nicht richtig oder bleibt grau Android & Cross-Platform Mobile Apps 10
W AlertDialog Eigenschaften existiert nicht mehr. Android & Cross-Platform Mobile Apps 14
W Wieso gehen Log nicht im Service? Android & Cross-Platform Mobile Apps 20
I Android ListView (Custom) soll auf Hardwaretasten nicht reagieren. Android & Cross-Platform Mobile Apps 10
CT9288 Zufällige Zahlengenerierung scheint nicht richtig zu funktionieren Android & Cross-Platform Mobile Apps 5
M App crasht und ich bekomme es nicht behoben.:( Android & Cross-Platform Mobile Apps 17
K Android Android In-App-Purchase lädt nicht Android & Cross-Platform Mobile Apps 0
Besset Android http request an interne ip adresse funktioniert nicht Android & Cross-Platform Mobile Apps 8
R Android Visualizer engine kann nicht initialisiert werden Android & Cross-Platform Mobile Apps 3
OSchriever Navigation drawer Strings ändern sich nicht Android & Cross-Platform Mobile Apps 0
W Code läuft unter SDK 27 aber nicht SDK 30 Android & Cross-Platform Mobile Apps 17
N Android Ich kann mit meiner App nicht auf die Datenbank zugreifen Android & Cross-Platform Mobile Apps 4
ruutaiokwu Android Selbst entwickelter SMTP-Client läuft auf PC, nicht aber auf Android Android & Cross-Platform Mobile Apps 9
W Android Wieso geht getApplicationContext() bei Toast, aber nicht bei AlertDialog.Builder? Android & Cross-Platform Mobile Apps 36
A Android Studio: while-Schleife beginnt nicht Android & Cross-Platform Mobile Apps 5
T Android SDK-Manager startet nicht in Eclipse Android & Cross-Platform Mobile Apps 5
J Download und speichern mit jsch klappt nicht Android & Cross-Platform Mobile Apps 5
J Service starte nicht mehr Android & Cross-Platform Mobile Apps 13
J Firebase und Emulator startet nicht Android & Cross-Platform Mobile Apps 2
L ListView aktuallisiert sich nicht Android & Cross-Platform Mobile Apps 15
J ArrayAdapter zeigt Liste nicht an Android & Cross-Platform Mobile Apps 0
L Android Animationen werden nicht angezeigt Android & Cross-Platform Mobile Apps 0
Excess Android Service läuft nicht in Sandby weiter Android & Cross-Platform Mobile Apps 2
J App funktioniert auf Android 5, auf 6 nicht Android & Cross-Platform Mobile Apps 2
K Log.v geht nicht Android & Cross-Platform Mobile Apps 4
L Android Android Studio - Exportierte APK funktioniert nicht Android & Cross-Platform Mobile Apps 6
L Android Methode funktioniert nicht unter Android Android & Cross-Platform Mobile Apps 3
L Android Java scheint XML nicht zu finden Android & Cross-Platform Mobile Apps 11
J android Spinner funktioniert nicht Android & Cross-Platform Mobile Apps 14
B Android osmdroid möchte nicht das es mapnik herunterlädt Android & Cross-Platform Mobile Apps 2
apple_pie1998 SharedPreferences funktionieren nicht... Android & Cross-Platform Mobile Apps 17
B Android Textdatei laden (klappt nicht) Android & Cross-Platform Mobile Apps 4
S Android null pointer (ich verstehs nicht) Android & Cross-Platform Mobile Apps 2
S Android Emulator startet nicht vollständig. Android & Cross-Platform Mobile Apps 0
S Neue Activity lässt sich nicht starten Android & Cross-Platform Mobile Apps 28
D Android Tabs nutzen - PagerTitleStrip haut nicht hin Android & Cross-Platform Mobile Apps 4
K MediaPlayer Soundklasse Start und Stop (stop funktioniert nicht) Android & Cross-Platform Mobile Apps 1
O Android Anfänger: Quellcode nicht gefunden Android & Cross-Platform Mobile Apps 3
B Timer geht nicht Android & Cross-Platform Mobile Apps 2
S Umlaute werden trotz UTF-8 nicht angezeigt? Android & Cross-Platform Mobile Apps 6
S SPLIT funktion bei STRING funktioniert nicht! Android & Cross-Platform Mobile Apps 4
J Android Breaking Point in Eclipse hält nicht an? Android & Cross-Platform Mobile Apps 5
J Android SimpleDateFormat parser funktioniert nicht richtig? Android & Cross-Platform Mobile Apps 4
L Android Apache POI: Datei speichern geht nicht Android & Cross-Platform Mobile Apps 1

Ähnliche Java Themen

Neue Themen


Oben