GCM Notification in Dialog form

3

I'm making an application that receives alert messages using Google Cloud Messaging, so it gets a message in the background App launches a notification that stays in the Android notification bar with this code below:

private void sendNotification(String message) {
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_stat_ic_notification)
            .setContentTitle("GCM Message")
            .setContentText(message)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

I'd like to display this notification as a Dialog in Android's home , something similar to what the App "Whoscall" does when receiving a call. How could this be done?

    
asked by anonymous 26.10.2015 / 18:57

1 answer

1

Erick, so I researched this seems to be a bad practice because it confuses the user and can disrupt the user in the task he is doing. The correct in this situation is to use the same notifications.

Place a notification with the two actions you want, it's the best way.

For more information: link

    
02.12.2015 / 11:40