Android - NotificationChanne

 
Vista:
Imágen de perfil de Francisco
Val: 466
Oro
Ha mantenido su posición en Android (en relación al último mes)
Gráfica de Android

NotificationChanne

Publicado por Francisco (358 intervenciones) el 26/01/2020 12:41:36
Estoy actualizando mi apicacion para android.os.Build.VERSION_CODES. O
El problema es que tengo un dialogo para cambiar el sonido uri del sonido de la notificacion en versiones anteriores abro el dialogo elijo el sonido y la notificacion se ejecuta con el sonido seleccionado,pero
si lo ejecuto en versiones posteriores nio cambia,solo cambia si desistalo la aplicacion el primer sonido que selecciono es el que se mantiene y ya no se puede cambiar.

Si la desistalo y selecciono por primera vez el sonido uri funciona,pero si lo quiero volver a cambiar este
se mantiene y ya no cambia.

Espero haberme explicado bien.

Alguna sugerencia.
Gracias por todo.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context. NOTIFICATION_SERVICE ) ;
            if (android.os.Build.VERSION. SDK_INT >= android.os.Build.VERSION_CODES. O ) {
                AudioAttributes audioAttributes = new AudioAttributes.Builder()
                        .setContentType(AudioAttributes. CONTENT_TYPE_SONIFICATION )
                        .setUsage(AudioAttributes.USAGE_NOTIFICATION )
                        .build() ;
                int importance = NotificationManager. IMPORTANCE_HIGH ;
                NotificationChannel notificationChannel = new
                        NotificationChannel( NOTIFICATION_CHANNEL_ID , "NOTIFICATION_CHANNEL_NAME" , importance) ;
                //notificationChannel.enableLights( true ) ;
                notificationChannel.setLightColor(Color. RED ) ;
               // notificationChannel.enableVibration( true ) ;
               // notificationChannel.setVibrationPattern( new long []{ 100 , 200 , 300 , 400 , 500 , 400 , 300 , 200 , 400 }) ;
                notificationChannel.setSound(uri , audioAttributes) ;
                mBuilder.setChannelId( NOTIFICATION_CHANNEL_ID ) ;
                assert mNotificationManager != null;
                mNotificationManager.createNotificationChannel(notificationChannel) ;
            }
            assert mNotificationManager != null;
            mNotificationManager.notify(( int ) System. currentTimeMillis (), mBuilder.build()) ;
 
        }else{
  // Aqqui va codigo Notificacion para versiones anteriores
 
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder