{"id":12800,"date":"2013-05-13T22:11:57","date_gmt":"2013-05-13T19:11:57","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=12800"},"modified":"2013-10-25T17:53:02","modified_gmt":"2013-10-25T14:53:02","slug":"modal-dialog-popup-from-android-widget-example","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html","title":{"rendered":"Modal dialog (popup) from Android widget example"},"content":{"rendered":"<p>In this example we are going to see \u00a0how you can create an Android widget in the home screen that can open a pop up dialogue box. As you know, Android Widgets are small applications that can basically do two things. Launch a new Activity when pressed, or display information that get updated at a decided time interval.<\/p>\n<h1>1. Introduction<\/h1>\n<p>Widgets make use of <a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/RemoteViews.html\"><code>RemoteViews<\/code><\/a> to display their user interface. <a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/RemoteViews.html\"><code>RemoteViews<\/code><\/a> can be executed by another process with the same permissions as the original application. This way the Widget runs with the permissions of its defining application. This is form the official Android Documentation : &#8221; <code>RemoteView<\/code> is a\u00a0class that describes a view hierarchy that can be displayed in another process. The hierarchy is inflated from a layout resource file, and this class provides some basic operations for modifying the content of the inflated hierarchy.&#8221;<\/p>\n<p>The user interface of a \u00a0Widget is defined by an <a href=\"http:\/\/developer.android.com\/reference\/android\/content\/BroadcastReceiver.html\"><code>BroadcastReceiver<\/code><\/a>. This <code>BroadcastReceiver<\/code> inflates the layout into the\u00a0<code>RemoteViews<\/code> of the Widget. \u00a0Then\u00a0<code>RemoteViews<\/code>\u00a0is delivered to Android, which updates the user interface at the home screen application.<\/p>\n<p>Widgets have limited functionality and styles compared to <code><a href=\"http:\/\/developer.android.com\/reference\/android\/app\/Activity.html\">Activities<\/a><\/code>. So you may need to thing some workarounds to do more complex stuff, like we want to do. And so to launch a pop up dialogue from our widget here&#8217;s what we do: When the widget is clicked we simply launch a new <code>Activity<\/code> with <code>android:theme=\"@android:style\/Theme.Dialog\"<\/code> property set in the configuration of the <code>Activity<\/code> in <code>AndroidManifest.xml<\/code>.<\/p>\n<p>To sum up the basic steps, we are going to:<\/p>\n<ul>\n<li>Create an Android Widget.<\/li>\n<li>Create an <code><a href=\"http:\/\/developer.android.com\/reference\/android\/content\/Intent.html\">Intent<\/a><\/code> that when sent to the <code>BroadcastReceiver<\/code> it marks the launching of the new Activity.<\/li>\n<li>Register a <code>ClickListener<\/code> to the widget. Thus when the widget is pressed the above <code>Intent<\/code> will be sent to the <code>BroadcastReceiver<\/code>.<\/li>\n<li>When this <code>Intent<\/code> is received, a new <code>Activity<\/code> that will look like a pop up dialog box, will be lauched.<\/li>\n<\/ul>\n<p>Let&#8217;s see how it&#8217;s done.<\/p>\n<h1>2. Create a new Android Widget<\/h1>\n<p>For this tutorial, we will use the following tools in a Windows 64-bit platform:<\/p>\n<ol>\n<li>JDK 1.7<\/li>\n<li>Eclipse 4.3 Kepler<\/li>\n<li>Android SKD 4.3<\/li>\n<\/ol>\n<h3>2.1 Create a new Android Project<\/h3>\n<p>Open Eclipse IDE and go to File -&gt; New -&gt; Project -&gt; Android -&gt; Android Application Project.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/new-android-project1.jpg\"><img decoding=\"async\" alt=\"new-android-project\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/new-android-project1.jpg\" width=\"513\" height=\"486\" \/><\/a><\/p>\n<p>You have to specify the Application Name, the Project Name and the Package name in the appropriate text fields and then click Next.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-android-appl.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18495\" alt=\"new-android-appl\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-android-appl.jpg\" width=\"508\" height=\"432\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-android-appl.jpg 508w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-android-appl-300x255.jpg 300w\" sizes=\"(max-width: 508px) 100vw, 508px\" \/><\/a><\/p>\n<p>In the next window un check \u201cCreate activity\u201d option as we will create the <code>PopUpActivity<\/code> later.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/configure-project-no-activity.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18497\" alt=\"configure-project-no-activity\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/configure-project-no-activity.jpg\" width=\"507\" height=\"410\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/configure-project-no-activity.jpg 507w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/configure-project-no-activity-300x242.jpg 300w\" sizes=\"(max-width: 507px) 100vw, 507px\" \/><\/a><\/p>\n<p>Click &#8220;Finish&#8221;.<\/p>\n<h3>2.2 Define a custom background shape for the widget<\/h3>\n<p>Go to the package explorer and open a <code>\/res\/drawable-*<\/code> folders.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/drawable-folders.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18498\" alt=\"drawable-folders\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/drawable-folders.jpg\" width=\"445\" height=\"466\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/drawable-folders.jpg 445w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/drawable-folders-286x300.jpg 286w\" sizes=\"(max-width: 445px) 100vw, 445px\" \/><\/a><\/p>\n<p>Right Click on one of the folders (I&#8217;ve picked <code>\/res\/drawble-hdpi<\/code>) -&gt; New -&gt; Other -&gt; Android -&gt; Android XML File<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-xml-file.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18500\" alt=\"new-xml-file\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-xml-file.jpg\" width=\"528\" height=\"526\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-xml-file.jpg 528w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-xml-file-150x150.jpg 150w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-xml-file-300x298.jpg 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-xml-file-200x200.jpg 200w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-xml-file-100x100.jpg 100w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-xml-file-42x42.jpg 42w\" sizes=\"(max-width: 528px) 100vw, 528px\" \/><\/a><\/p>\n<p>From the &#8220;Root Element&#8221; list select shape and the give the file the name\u00a0<code>custom_shape.xml:<\/code><\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/custom-xml-shape.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18499\" alt=\"custom-xml-shape\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/custom-xml-shape.jpg\" width=\"531\" height=\"524\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/custom-xml-shape.jpg 531w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/custom-xml-shape-300x296.jpg 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/custom-xml-shape-100x100.jpg 100w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/custom-xml-shape-42x42.jpg 42w\" sizes=\"(max-width: 531px) 100vw, 531px\" \/><\/a><\/p>\n<p>Now, open that file and paste the following code , describing the layout of a simple shape.<\/p>\n<p><em><span style=\"text-decoration: underline;\">custom_shape.xml:<\/span><\/em><\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;shape xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:shape=\"rectangle\" &gt;\r\n\r\n    &lt;gradient\r\n        android:angle=\"90\"\r\n        android:endColor=\"#333\"\r\n        android:startColor=\"#333\" \/&gt;\r\n\r\n    &lt;corners\r\n        android:bottomLeftRadius=\"2dp\"\r\n        android:bottomRightRadius=\"2dp\"\r\n        android:topLeftRadius=\"2dp\"\r\n        android:topRightRadius=\"2dp\" \/&gt;\r\n\r\n    &lt;stroke\r\n        android:width=\"2dp\"\r\n        android:color=\"#333\" \/&gt;\r\n\r\n&lt;\/shape&gt;<\/pre>\n<h3>2.3 Define a simple layout for the widget<\/h3>\n<p>Navigate to <code>res\/layout<\/code> folder on the Package Explorer. Right Click on the folder -&gt; New -&gt; Other -&gt; Android -&gt; Android XML Layout File. Create the file \u00a0with name <code>widget_layout<\/code>.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/widget-layout.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18501\" alt=\"widget-layout\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/widget-layout.jpg\" width=\"519\" height=\"458\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/widget-layout.jpg 519w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/widget-layout-300x264.jpg 300w\" sizes=\"(max-width: 519px) 100vw, 519px\" \/><\/a><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>And paste the following code:<\/p>\n<p><em><span style=\"text-decoration: underline;\"><code>widget_layout.xml<\/code>:<\/span><\/em><\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:id=\"@+id\/linearLayout\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    android:layout_margin=\"8dip\"\r\n    android:background=\"@drawable\/custom_shape\" &gt;\r\n\r\n    &lt;TextView\r\n        android:id=\"@+id\/myText\"\r\n        style=\"@android:style\/TextAppearance.Medium\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"match_parent\"\r\n        android:layout_gravity=\"center\"\r\n        android:layout_margin=\"4dip\"\r\n        android:gravity=\"center_horizontal|center_vertical\"\r\n        android:text=\"Press Me\"\r\n        android:textColor=\"#FFF\" &gt;\r\n\r\n    &lt;\/TextView&gt;\r\n\r\n&lt;\/LinearLayout&gt;<\/pre>\n<h3>2.4 Create the <code>AppWidgetProvider<\/code> XML description file.<\/h3>\n<p>Go to File -&gt; New -&gt; Other -&gt; Android -&gt; Android XML File. From the &#8220;Resource Type&#8221; list select &#8220;AppWidget Provider&#8221; and name the file <code>widget_provider.xml.<\/code><\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-widget-provider.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18503\" alt=\"new-widget-provider\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-widget-provider.jpg\" width=\"491\" height=\"432\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-widget-provider.jpg 491w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-widget-provider-300x263.jpg 300w\" sizes=\"(max-width: 491px) 100vw, 491px\" \/><\/a><\/p>\n<p>You will find the file under the newly created <code>\/res\/xml<\/code> folder:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-folder.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18504\" alt=\"new-folder\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-folder.jpg\" width=\"388\" height=\"563\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-folder.jpg 388w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-folder-206x300.jpg 206w\" sizes=\"(max-width: 388px) 100vw, 388px\" \/><\/a><\/p>\n<p>Open the file and paste the following code, which is basically meta data for the <code>AppWidgetProvider.<\/code><\/p>\n<p><em><span style=\"text-decoration: underline;\">widget_provider.xml:<\/span><\/em><\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;appwidget-provider xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:initialLayout=\"@layout\/widget_layout\"\r\n    android:minHeight=\"50dp\"\r\n    android:minWidth=\"120dp\" &gt;\r\n\r\n&lt;\/appwidget-provider&gt;<\/pre>\n<h3>2.5 Create the <code>AppWidgetProvider<\/code> class<\/h3>\n<p>Now create a new class that extends <code>AppWidgetProvider<\/code>, under <code>com.javacodegeeks.android.androidwidgetdialog<\/code> package. This will be the <code>BroadcastReceiver<\/code> of the widget.<\/p>\n<p><em><span style=\"text-decoration: underline;\">AndroidWidget.java:<\/span><\/em><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.androidwidgetdialog;\r\n\r\nimport android.app.PendingIntent;\r\nimport android.appwidget.AppWidgetManager;\r\nimport android.appwidget.AppWidgetProvider;\r\nimport android.content.ComponentName;\r\nimport android.content.Context;\r\nimport android.content.Intent;\r\nimport android.widget.RemoteViews;\r\n\r\npublic class AndroidWidget extends AppWidgetProvider {\r\n\r\n\tprivate static final String SHOW_POPUP_DIALOG_ACTION = \"com.javacodegeeks.android.showpopupdialog\";\r\n\r\n\t@Override\r\n\tpublic void onUpdate(Context context, AppWidgetManager appWidgetManager,\r\n\t\t\tint[] appWidgetIds) {\t\r\n\r\n\t\tComponentName thisWidget = new ComponentName(context,\r\n\t\t\t\tAndroidWidget.class);\r\n\r\n\t\t\/\/ Obtain all instances of our widget\r\n\t\t\/\/ Remember that you can have as many instances of the same widget as you want on the home screen \r\n\r\n\t\tint[] allWidgetInstancesIds = appWidgetManager.getAppWidgetIds(thisWidget);\r\n\t\tfor (int widgetId : allWidgetInstancesIds) {\r\n\r\n\t\t\tRemoteViews remoteViews = new RemoteViews(context.getPackageName(),\r\n\t\t\t\t\tR.layout.widget_layout);\r\n\r\n\t\t\t\/\/ Create an intent that when received will launch the PopUpActivity\r\n\t\t\tIntent intent = new Intent(context, AndroidWidget.class);\r\n\t\t\tintent.setAction(SHOW_POPUP_DIALOG_ACTION);\r\n\r\n\t\t\tPendingIntent pendingIntent = PendingIntent.getBroadcast(context,\r\n\t\t\t\t\t0, intent, PendingIntent.FLAG_UPDATE_CURRENT);\r\n\r\n\t\t\t\/\/ Set up the onClickListener of the widget\r\n\t\t\t\/\/ Now, when the widget is pressed the pendingIntent will be sent\r\n\r\n\t\t\tremoteViews.setOnClickPendingIntent(R.id.myText, pendingIntent);\r\n\r\n\t\t\tappWidgetManager.updateAppWidget(widgetId, remoteViews);\r\n\r\n\t\t}\r\n\r\n\t\tsuper.onUpdate(context, appWidgetManager, appWidgetIds);\r\n\r\n\t}\r\n\r\n\t@Override\r\n\tpublic void onReceive(final Context context, Intent intent) {\r\n\r\n\t\t\/\/ If the intent is the one that we've defined to launch the pop up dialog\r\n\t\t\/\/ then create and launch the PopUpActivity\r\n\t\tif (intent.getAction().equals(SHOW_POPUP_DIALOG_ACTION)) {\r\n\r\n\t\t\tIntent popUpIntent = new Intent(context, PopUpActivity.class);\r\n\t\t\tpopUpIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\r\n\t\t\tcontext.startActivity(popUpIntent);\r\n\r\n\t\t}\r\n\r\n\t\tsuper.onReceive(context, intent);\r\n\r\n\t}\r\n\r\n}<\/pre>\n<p>As you can see we use a <code><a href=\"http:\/\/developer.android.com\/reference\/android\/app\/PendingIntent.html#getBroadcast(android.content.Context, int, android.content.Intent, int)\">PendingIntent<\/a><\/code> instance. A <code>PendingIntent<\/code> is a description of an Intent and target action to perform with it. When you give a <code>PendingIntent<\/code> to another application, you are granting it the right to perform the operation you have specified with the same permissions and identity. And thus, you should be careful about how you use the <code>PendingIntent<\/code>. In this example we&#8217;ve obtained the <code>PendingIntent<\/code> instance calling <code>getBroadcast<\/code> method. This method will retrieve a <code>PendingIntent<\/code> that will perform a broadcast, like calling <code>Context.sendBroadcast()<\/code>.<\/p>\n<p>Now the flow of the execution goes like this:<\/p>\n<ol>\n<li>As defined, the <code>onUpdate<\/code> method is executed only once, when the widget is installed on the home screen. You can set up a time interval to execute the <code>onUpdate<\/code> method by defining the <code>android:updatePeriodMillis<\/code> property on the <code>widget_provider.xml<\/code> file. So when, <code>onUpdate<\/code> method is executed, first we retrieve all the instance ids of the widget that the user has installed on the home screen.<\/li>\n<li>Then we create a new <code>Intent<\/code> with action <code>com.javacodegeeks.android.showpopupdialog<\/code>. Retrieve a new broadcasting <code>PendingIntent<\/code><\/li>\n<li>Register an <code>OnClickPendingIntent<\/code> listener to the <code>RemoteView<\/code> of each widget.<\/li>\n<li>Now when the user clicks on the Widget, the <code>Intent<\/code> with action <code>com.javacodegeeks.android.showpopupdialog<\/code> will be broadcast. This is the Intent created in line 32 of the above code (used also to create the <code>PendingIntent<\/code> instance).<\/li>\n<li>The Intent will be received and the <code>onReceive<\/code> will be executed. If the <code>Intent<\/code> received has <code>com.javacodegeeks.android.showpopupdialog<\/code> action the <code>PopUpActivity<\/code> class will be launched.<\/li>\n<\/ol>\n<p>Now let&#8217;s see the code of the\u00a0<code>PopUpActivity.<\/code><\/p>\n<h1>3. Create the\u00a0<code>PopUpActivity<\/code><\/h1>\n<p><code>PopUpActivity<\/code> is a simple <code>Activity<\/code> class that will be launched as a Dialogue box.<\/p>\n<p>Go to the Package Explorer and Right click on the <code>com.javacodegeeks.android.androidwidgetdialog<\/code> package -&gt; New -&gt; Other -&gt; Android -&gt; Android Activity.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-activity.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18505\" alt=\"new-activity\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-activity.jpg\" width=\"525\" height=\"500\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-activity.jpg 525w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-activity-300x285.jpg 300w\" sizes=\"(max-width: 525px) 100vw, 525px\" \/><\/a><\/p>\n<p>Set the name to &#8220;PopUpActivity&#8221;. As you can see the layout file of this activity will be automatically created with name &#8220;activity_pop_up.xml&#8221;.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-pop-up-activity.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18506\" alt=\"new-pop-up-activity\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-pop-up-activity.jpg\" width=\"614\" height=\"462\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-pop-up-activity.jpg 614w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-pop-up-activity-300x225.jpg 300w\" sizes=\"(max-width: 614px) 100vw, 614px\" \/><\/a><\/p>\n<p>To set the layout of the activity open <code>\/res\/layout\/activity_pop_up.xml<\/code> file and paste the following code.<\/p>\n<p><em><span style=\"text-decoration: underline;\">activity_pop_up.xml:<\/span><\/em><\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"220dp\"\r\n    android:layout_height=\"wrap_content\" \r\n    android:gravity=\"center_horizontal\"\r\n    android:orientation=\"vertical\" &gt;\r\n\r\n    &lt;TextView\r\n        android:id=\"@+id\/mytxt\"\r\n        android:layout_width=\"fill_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_marginBottom=\"10dp\"\r\n        android:layout_marginLeft=\"0dp\"\r\n        android:layout_marginRight=\"0dp\"\r\n        android:layout_marginTop=\"5dp\"\r\n        android:gravity=\"center_horizontal\"\r\n        android:textColor=\"#FFF\"\r\n        android:textSize=\"13sp\" \/&gt;\r\n\r\n    &lt;Button\r\n        android:id=\"@+id\/closBtn\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:text=\"Close\" \/&gt;\r\n\r\n&lt;\/LinearLayout&gt;<\/pre>\n<p>This is the code of the <code>PopUpActivity<\/code> class.<\/p>\n<p><em><span style=\"text-decoration: underline;\">PopUpActivity.java:<\/span><\/em><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.androidwidgetdialog;\r\n\r\nimport java.util.Random;\r\n\r\nimport android.app.Activity;\r\nimport android.os.Bundle;\r\nimport android.view.Menu;\r\nimport android.view.View;\r\nimport android.view.View.OnClickListener;\r\nimport android.view.Window;\r\nimport android.widget.Button;\r\nimport android.widget.TextView;\r\n\r\npublic class PopUpActivity extends Activity {\r\n\r\n\t@Override\r\n\tprotected void onCreate(Bundle savedInstanceState) {\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\t\trequestWindowFeature(Window.FEATURE_NO_TITLE);\r\n\t\tsetContentView(R.layout.activity_pop_up);\r\n\r\n\t\tString dialogText = \"Dialog Box : \" + (new Random().nextInt(100));\r\n\t\tTextView txt = (TextView) findViewById(R.id.mytxt);\r\n\t\ttxt.setText(dialogText);\r\n\r\n\t\tButton dismissbutton = (Button) findViewById(R.id.closBtn);\r\n\t\tdismissbutton.setOnClickListener(new OnClickListener() {\r\n\t\t\t@Override\r\n\t\t\tpublic void onClick(View v) {\r\n\t\t\t\tPopUpActivity.this.finish();\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n}<\/pre>\n<p>Nothing spacial in the above code. We simple set the value of the <code>mytxt<\/code> <code>TextView<\/code>. And we register a <code>ClickListener<\/code> for the dismiss button. When the button is pressed the <code>PopUpActivity<\/code> will be terminated.<\/p>\n<h1>4. <code>AndroidManifest.xml<\/code> Configuration<\/h1>\n<p>This is a very important step of the tutorial. Open <code>AndroidManifest.xml<\/code> file and paste the following code:<\/p>\n<p><em><span style=\"text-decoration: underline;\">AndroidManifest.xml:<\/span><\/em><\/p>\n<pre class=\"brush:xml; highlight:[34]\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;manifest xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    package=\"com.javacodegeeks.android.androidwidgetdialog\"\r\n    android:versionCode=\"1\"\r\n    android:versionName=\"1.0\" &gt;\r\n\r\n    &lt;uses-sdk\r\n        android:minSdkVersion=\"8\"\r\n        android:targetSdkVersion=\"18\" \/&gt;\r\n\r\n    &lt;application\r\n        android:allowBackup=\"true\"\r\n        android:icon=\"@drawable\/ic_launcher\"\r\n        android:label=\"@string\/app_name\"\r\n        android:theme=\"@style\/AppTheme\" &gt;\r\n\r\n        &lt;receiver\r\n            android:name=\".AndroidWidget\"\r\n            android:icon=\"@drawable\/ic_launcher\"\r\n            android:label=\"Android Custom Widget\" &gt;\r\n            &lt;intent-filter&gt;\r\n                &lt;action android:name=\"com.javacodegeeks.android.showpopupdialog\" \/&gt;\r\n                &lt;action android:name=\"android.appwidget.action.APPWIDGET_UPDATE\" \/&gt;\r\n            &lt;\/intent-filter&gt;\r\n\r\n            &lt;meta-data\r\n                android:name=\"android.appwidget.provider\"\r\n                android:resource=\"@xml\/widget_provider\" \/&gt;\r\n        &lt;\/receiver&gt;\r\n\r\n        &lt;activity\r\n            android:name=\"com.javacodegeeks.android.androidwidgetdialog.PopUpActivity\"\r\n            android:label=\"@string\/title_activity_pop_up\"\r\n            android:theme=\"@android:style\/Theme.Dialog\" &gt;\r\n        &lt;\/activity&gt;\r\n    &lt;\/application&gt;\r\n\r\n&lt;\/manifest&gt;<\/pre>\n<p>As you can see we&#8217;ve set up a receiver, that registers our code&gt;AppWidgetProvider for our application, that can receive broadcasts<\/p>\n<ol>\n<li>&lt;action android:name=&#8221;com.javacodegeeks.android.showpopupdialog&#8221; \/&gt;<\/li>\n<li>&lt;action android:name=&#8221;android.appwidget.action.APPWIDGET_UPDATE&#8221; \/&gt;<\/li>\n<\/ol>\n<p>The first one is the Intent that we&#8217;ve registered ourselves. The second one is an Intent send by Android. We also provide the meta data to the the <code>AppWidgetProvider<\/code>, pointing to the <code>widget_provider.xml<\/code> resource file we&#8217;ve created earlier.<\/p>\n<p>The important bit is in line 34, where we define the theme of the application as <code>android:theme=\"@android:style\/Theme.Dialog\"<\/code>. This will create an activity with a pop up dialogue theme<\/p>\n<p>Let&#8217;s see how it looks like on the emulator.<\/p>\n<h1>5. Run the Apllication<\/h1>\n<p>When your run the application and the emulator launches go to the Apps button on the home screen :<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-screen.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18507\" alt=\"main-screen\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-screen.jpg\" width=\"256\" height=\"470\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-screen.jpg 256w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-screen-163x300.jpg 163w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>The tap on &#8220;Widgets&#8221;. Drag and drop your Widget to the home screen<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/widgets.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18508\" alt=\"widgets\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/widgets.jpg\" width=\"256\" height=\"470\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/widgets.jpg 256w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/widgets-163x300.jpg 163w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>Here it is:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/widget-onscreen.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18509\" alt=\"widget-onscreen\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/widget-onscreen.jpg\" width=\"256\" height=\"470\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/widget-onscreen.jpg 256w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/widget-onscreen-163x300.jpg 163w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>Now when you click on the Widget:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/dialog.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-18510\" alt=\"dialog\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/dialog.jpg\" width=\"256\" height=\"470\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/dialog.jpg 256w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/dialog-163x300.jpg 163w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>That&#8217;s it.<\/p>\n<h3>Download the Eclipse Project<\/h3>\n<p>This was an Android example on how to create\u00a0Modal dialog (popup) from Android widget. Download the Eclipse Project of this tutorial:\u00a0<a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/AndroidWidgetDialog.zip\">AndroidWidgetDialog.zip<\/a><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/AndroidLayoutsExample.zip\"><br \/>\n<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this example we are going to see \u00a0how you can create an Android widget in the home screen that can open a pop up dialogue box. As you know, Android Widgets are small applications that can basically do two things. Launch a new Activity when pressed, or display information that get updated at a &hellip;<\/p>\n","protected":false},"author":7,"featured_media":46,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-12800","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android-core"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Modal dialog (popup) from Android widget example<\/title>\n<meta name=\"description\" content=\"In this example we are going to see \u00a0how you can create an Android widget in the home screen that can open a pop up dialogue box. As you know, Android\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Modal dialog (popup) from Android widget example\" \/>\n<meta property=\"og:description\" content=\"In this example we are going to see \u00a0how you can create an Android widget in the home screen that can open a pop up dialogue box. As you know, Android\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-05-13T19:11:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-10-25T14:53:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nikos Maravitsas\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nikos Maravitsas\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/modal-dialog-popup-from-android-widget-example.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/modal-dialog-popup-from-android-widget-example.html\"},\"author\":{\"name\":\"Nikos Maravitsas\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/aca65ecdda8de63ce629d2754da61f11\"},\"headline\":\"Modal dialog (popup) from Android widget example\",\"datePublished\":\"2013-05-13T19:11:57+00:00\",\"dateModified\":\"2013-10-25T14:53:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/modal-dialog-popup-from-android-widget-example.html\"},\"wordCount\":1162,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/modal-dialog-popup-from-android-widget-example.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"articleSection\":[\"Android Core\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/modal-dialog-popup-from-android-widget-example.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/modal-dialog-popup-from-android-widget-example.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/modal-dialog-popup-from-android-widget-example.html\",\"name\":\"Modal dialog (popup) from Android widget example\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/modal-dialog-popup-from-android-widget-example.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/modal-dialog-popup-from-android-widget-example.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"datePublished\":\"2013-05-13T19:11:57+00:00\",\"dateModified\":\"2013-10-25T14:53:02+00:00\",\"description\":\"In this example we are going to see \u00a0how you can create an Android widget in the home screen that can open a pop up dialogue box. As you know, Android\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/modal-dialog-popup-from-android-widget-example.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/modal-dialog-popup-from-android-widget-example.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/modal-dialog-popup-from-android-widget-example.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/modal-dialog-popup-from-android-widget-example.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Android Core\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\\\/android-core\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Modal dialog (popup) from Android widget example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/aca65ecdda8de63ce629d2754da61f11\",\"name\":\"Nikos Maravitsas\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3969f52bbf541170fe1ae074a6848e1085b8180438db323f626a436a7d19b23f?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3969f52bbf541170fe1ae074a6848e1085b8180438db323f626a436a7d19b23f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3969f52bbf541170fe1ae074a6848e1085b8180438db323f626a436a7d19b23f?s=96&d=mm&r=g\",\"caption\":\"Nikos Maravitsas\"},\"description\":\"Nikos has graduated from the Department of Informatics and Telecommunications of The National and Kapodistrian University of Athens.\",\"sameAs\":[\"http:\\\/\\\/www.javacodegeeks.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/nikos-maravitsas\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Modal dialog (popup) from Android widget example","description":"In this example we are going to see \u00a0how you can create an Android widget in the home screen that can open a pop up dialogue box. As you know, Android","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html","og_locale":"en_US","og_type":"article","og_title":"Modal dialog (popup) from Android widget example","og_description":"In this example we are going to see \u00a0how you can create an Android widget in the home screen that can open a pop up dialogue box. As you know, Android","og_url":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-05-13T19:11:57+00:00","article_modified_time":"2013-10-25T14:53:02+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","type":"image\/jpeg"}],"author":"Nikos Maravitsas","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Nikos Maravitsas","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html"},"author":{"name":"Nikos Maravitsas","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/aca65ecdda8de63ce629d2754da61f11"},"headline":"Modal dialog (popup) from Android widget example","datePublished":"2013-05-13T19:11:57+00:00","dateModified":"2013-10-25T14:53:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html"},"wordCount":1162,"commentCount":4,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","articleSection":["Android Core"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html","url":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html","name":"Modal dialog (popup) from Android widget example","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","datePublished":"2013-05-13T19:11:57+00:00","dateModified":"2013-10-25T14:53:02+00:00","description":"In this example we are going to see \u00a0how you can create an Android widget in the home screen that can open a pop up dialogue box. As you know, Android","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/modal-dialog-popup-from-android-widget-example.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Android","item":"https:\/\/www.javacodegeeks.com\/category\/android"},{"@type":"ListItem","position":3,"name":"Android Core","item":"https:\/\/www.javacodegeeks.com\/category\/android\/android-core"},{"@type":"ListItem","position":4,"name":"Modal dialog (popup) from Android widget example"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/aca65ecdda8de63ce629d2754da61f11","name":"Nikos Maravitsas","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3969f52bbf541170fe1ae074a6848e1085b8180438db323f626a436a7d19b23f?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3969f52bbf541170fe1ae074a6848e1085b8180438db323f626a436a7d19b23f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3969f52bbf541170fe1ae074a6848e1085b8180438db323f626a436a7d19b23f?s=96&d=mm&r=g","caption":"Nikos Maravitsas"},"description":"Nikos has graduated from the Department of Informatics and Telecommunications of The National and Kapodistrian University of Athens.","sameAs":["http:\/\/www.javacodegeeks.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/nikos-maravitsas"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/12800","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=12800"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/12800\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/46"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=12800"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=12800"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=12800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}