Visualizzazione dei risultati da 1 a 5 su 5

Visualizzazione discussione

  1. #1

    [ANDROID] Notifica non appare sul drawer

    Salve,

    Ho da poco, prima di andare in vacanza, re-iniziato ( visto che l'avevo già cominciato da tempo ma lasciato perdere per motivi di mancanza di tempo ) a studiarmi come creare app per andoird con java, sto seguendo la guida su questo sito, ed avrei il problema.

    Sono arrivato alla lezione su come gestire le notifiche, questa qui: https://www.html.it/pag/48857/le-notifiche-in-android/

    Seguendo la lezione ho creato questa funzione:

    codice:
    public void makeNotification(View vw){
        String channel_id ="chID";
        String channel_name="chNAME";
        String channel_description="ch_DESK";
    
        NotificationManager notificationManager = getSystemService(NotificationManager.class);
    
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel(channel_id, channel_name, NotificationManager.IMPORTANCE_DEFAULT);
            channel.setDescription(channel_description);
            notificationManager.createNotificationChannel(channel);
        }
    
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channel_id)
                .setSmallIcon(android.R.drawable.star_on)
                .setContentTitle("Nuova notifica!!")
                .setContentText("Sappi che è successo questo nel tuo sistema: ...")
                .setPriority(NotificationCompat.PRIORITY_DEFAULT);
    
        notificationManager.notify(0, builder.build());
    }

    Che richiamo tramite l'attributo onClick del bottone sull'activity.

    Il problema è che: quando premo il bottone la notifica non appare, cosa sbaglio?
    Ultima modifica di LeleFT; 30-08-2023 a 10:03

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.