Pregunta

I implemented the code sample from Google notifications example. It works fine till Android 4.2.2 but doesn't since 4.3 (on my Nexus 7 2013)... Am I the only one to get this problem ? Did I miss a new notification method ? Here is my simple code :

    final int NOTIFICATION_ID = 1;
        NotificationManager mNotificationManager;

        mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, HomeActivity.class), 0);

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.icon)
        .setContentTitle("Title")
        .setStyle(new NotificationCompat.BigTextStyle()
        .bigText(""))
        .setContentText("Message");

        mBuilder.setContentIntent(contentIntent);
        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());

Thanks !

¿Fue útil?

Solución

Well, in fact the problem was coming from a bad coding of my php files which for whatever reasons would skip the request for adding a new user (registration_id) to the database. The GCM server could not know about my device because it wasn't added to the database...

The point is that it works in Android 4.3 !

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top