# Android: display a Dialog from an AppWidget

DevFeed: [Android: display a Dialog from an AppWidget](<https://devfeed.tech/articles/android-display-a-dialog-from-an-appwidget-21763.md>)

Original publisher: [Read original article](<https://enoent.fr/posts/android-display-a-dialog-from-an-appwidget/>)

Author: Marc Plano-Lesay

Published: 2014-04-06T20:27:19Z

Content type: tutorial

Language: en

Sources: [Marc Plano-Lesay](<https://devfeed.tech/sources/marc-plano-lesay.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [App](<https://devfeed.tech/topics/app.md>), [Code](<https://devfeed.tech/topics/code.md>), [dialog](<https://devfeed.tech/topics/dialog.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [app](<https://devfeed.tech/tags/app.md>), [code](<https://devfeed.tech/tags/code.md>), [context](<https://devfeed.tech/tags/context.md>), [dialog](<https://devfeed.tech/tags/dialog.md>), [github](<https://devfeed.tech/tags/github.md>), [widget](<https://devfeed.tech/tags/widget.md>)

## AI overview

This tutorial explains how to display an Android dialog from an AppWidget by launching an activity with an activity context. It covers making the activity transparent and hiding it from history and recent apps, applying an appropriate dialog theme, reusing the activity for multiple dialogs, and finishing it when dialogs are dismissed.

## Source excerpt

Issue When you want to display a dialog, you don't only need a context, you need an activity context. From an activity, displaying a dialog is pretty straightforward: Display a dialog from an activity new AlertDialog.Builder(MyActivity.this) .setTitle("Dialog title") .setMessage("Dialog message") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Handle a positive answer } }) .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Handle a negative answer } }) .setIcon(R.drawable.ic_dialog_alert) .show(); Okay, that's a pretty usual code sample. But what about displaying it from an app-widget?