jeudi 28 mai 2015

FullScreenIntent only appears if I clear the notification

I'm trying to launch a FullScreenIntent from a service working in the background, but I realised that the intent would not be shown another time if I do not clear the notification from the task bar. I have tried removing the notification by removing

.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Notification")
.setContentText("A client is calling")

but that just removes my option of clearing the notification. Can somebody help?

My code is as shown:

                    NotificationCompat.Builder mBuilder =
                            new NotificationCompat.Builder(this)
                                    .setSmallIcon(R.drawable.ic_launcher)
                                    .setContentTitle("Notification")
                                    .setContentText("A client is calling")
                                    .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                                    .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
                                    .setAutoCancel(true);
                    Intent resultIntent = new Intent(this, MainActivity.class);
                    String strName = ((String) message).substring(9);
                    resultIntent.putExtra("Msg",strName);
    // Because clicking the notification opens a new ("special") activity, there's
    // no need to create an artificial back stack.
                    PendingIntent resultPendingIntent =
                            PendingIntent.getActivity(
                                    this,
                                    0,
                                    resultIntent,
                                    PendingIntent.FLAG_CANCEL_CURRENT
                            );

                    mBuilder.setFullScreenIntent(resultPendingIntent,true);
                    int mNotificationId = 001;
    // Gets an instance of the NotificationManager service
                    NotificationManager mNotifyMgr =
                            (NotificationManager)this.getSystemService(this.NOTIFICATION_SERVICE);
    // Builds the notification and issues it.
                    Notification m = mBuilder.build();
                    m.flags = Notification.FLAG_AUTO_CANCEL;
                    mNotifyMgr.notify(mNotificationId, m);

Aucun commentaire:

Enregistrer un commentaire