Я triying сделать следующее:AlertDialog не отображается после нажатия Notification
Мое приложение имеет AsyncTask, что в конечном итоге создает AlertDialog просить пользователя isert код. Это может произойти, когда приложение находится на переднем плане, поэтому я запускаю уведомление для информирования пользователя, и моя идея заключается в том, что после нажатия на уведомление отображается основное действие с помощью AlertDialog.
Тем не менее, происходит то, что, как только пользователь нажимает на уведомление, отображается только активность, в которой должен отображаться параметр AlertDialog, и я получаю исключение WindowLeaked, которое, вероятно, вызвано диалогом.
Существует код, который я использую для запуска уведомления (от метода onProgressUpdate из AsyncTask):
public void launch_notification(){
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(context.getString(R.string.opening_request_notification_title))
.setContentText(context.getString(R.string.opening_request_notification_text));
/* The intent must be created with an specific content and then frozen to be used
later using a pending intent.
*/
Intent notificationIntent = new Intent(context, Main.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notificationBuilder.setContentIntent(pendingIntent);
notificationBuilder.setAutoCancel(true);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
}
Любая идея будет приветствоваться. Спасибо большое :)