{"id":7752,"date":"2013-12-26T13:53:01","date_gmt":"2013-12-26T11:53:01","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=7752"},"modified":"2018-06-12T12:54:27","modified_gmt":"2018-06-12T09:54:27","slug":"android-alert-dialog-example-2","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/","title":{"rendered":"Android Alert Dialog Example"},"content":{"rendered":"<p>In this post, we feature a comprehensive Android Alert Dialog Example. Sometimes in our applications we want to alert the user for an event and\/or ask him\/her about taking a decision. For this purpose <a href=\"http:\/\/developer.android.com\/reference\/android\/app\/AlertDialog.html\" target=\"_blank\" rel=\"noopener\"><code>AlertDialog<\/code><\/a> class can be used, where a message and one, two or three buttons are displayed in a popup window.<\/p>\n<p>In this example, we are going to show an <code>AlertDialog<\/code> with three different buttons, where each one leads to a different action.<br \/>\nFor 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.2 Juno<\/li>\n<li>Android SDK 4.4<\/li>\n<\/ol>\n<h2>1. Create a New Android Application Project<\/h2>\n<p>Open Eclipse IDE and go to File \u2192 New \u2192 Project \u2192 Android Application Project.<\/p>\n<p>Fill in the name of the application, the project and the package in the appropriate fields and then click Next.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialProj1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-7753 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialProj1.png\" alt=\"Android Alert Dialog - AlertDialProj1\" width=\"497\" height=\"482\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialProj1.png 497w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialProj1-300x290.png 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialProj1-42x42.png 42w\" sizes=\"(max-width: 497px) 100vw, 497px\" \/><\/a><\/p>\n<p>In the next window, check the \u201cCreate Activity\u201d option. The new created activity will be the main activity of your project. Then press Next button.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialProj2.png\"><img decoding=\"async\" class=\"aligncenter wp-image-7754 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialProj2.png\" alt=\"Android Alert Dialog - AlertDialProj2\" width=\"497\" height=\"482\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialProj2.png 497w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialProj2-300x290.png 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialProj2-42x42.png 42w\" sizes=\"(max-width: 497px) 100vw, 497px\" \/><\/a><\/p>\n<p>In \u201cConfigure Launcher Icon\u201d window you should choose the icon you want to have in your app. We will use the default icon of android, so press Next button.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject3.png\"><img decoding=\"async\" class=\"aligncenter wp-image-7274 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject3.png\" alt=\"Android Alert Dialog - createProject3!\" width=\"563\" height=\"572\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject3.png 563w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject3-295x300.png 295w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject3-42x42.png 42w\" sizes=\"(max-width: 563px) 100vw, 563px\" \/><\/a><\/p>\n<p>Select the \u201cBlank Activity\u201d option and click Next.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject4.png\"><img decoding=\"async\" class=\"aligncenter wp-image-7275 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject4.png\" alt=\"Android Alert Dialog - createProject4!\" width=\"563\" height=\"572\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject4.png 563w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject4-295x300.png 295w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject4-42x42.png 42w\" sizes=\"(max-width: 563px) 100vw, 563px\" \/><\/a><\/p>\n<p>Specify a name for the new Activity and a name for the layout description of your app. The .xml file for the layout will automatically be created in the\u00a0<code>res\/layout<\/code>\u00a0folder. Finally, click Finish.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject5.png\"><img decoding=\"async\" class=\"aligncenter wp-image-7276 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject5.png\" alt=\"Android Alert Dialog - createProject5!\" width=\"522\" height=\"555\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject5.png 522w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject5-282x300.png 282w\" sizes=\"(max-width: 522px) 100vw, 522px\" \/><\/a><\/p>\n<p>You can see the structre of the AlertDialogTest project in the picture below.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialStructure.png\"><img decoding=\"async\" class=\"aligncenter wp-image-7755 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialStructure.png\" alt=\"Android Alert Dialog - AlertDialStructure\" width=\"343\" height=\"585\" \/><\/a><\/p>\n<h2>2. Create the layout of the Main Activity<\/h2>\n<p>We will create a simple interface, so we will add a <code>TextView<\/code> and a <code>Button<\/code>, which enables the <code>AlertDialog<\/code> box.<\/p>\n<p>Open <code>res\/layout\/activity_main.xml<\/code> file and go to the xml tab. Then paste the following.<\/p>\n<p><em><u>activity_main.xml:<\/u><\/em><\/p>\n<pre class=\"brush:xml\">&lt;RelativeLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    tools:context=\".MainActivity\" &gt;\r\n\r\n    &lt;TextView\r\n        android:id=\"@+id\/text\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:text=\"Main activity of the app...\" \/&gt;\r\n\r\n    &lt;Button\r\n        android:id=\"@+id\/button\"\r\n        android:layout_width=\"fill_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_below=\"@+id\/text\"\r\n        android:layout_marginTop=\"20dp\"\r\n        android:text=\"Show Alert Box\" \/&gt;\r\n\r\n&lt;\/RelativeLayout&gt;\r\n<\/pre>\n<h2>3. Code the Main Activity<\/h2>\n<p><code>AlertDialog<\/code> is a subclass of <a href=\"http:\/\/developer.android.com\/reference\/android\/app\/Dialog.html\" target=\"_blank\" rel=\"noopener\"><code>Dialog<\/code><\/a> that can display up to three <code>Buttons<\/code>. In order to create the interface of the alert box, <a href=\"http:\/\/developer.android.com\/reference\/android\/app\/AlertDialog.Builder.html\" target=\"_blank\" rel=\"noopener\"><code>AlertDialog.Builder<\/code><\/a> should be called. <code>AlertDialogBuilder<\/code> class provides us positive, negative and neutral buttons by setting the <code>setPositiveButton<\/code>, <code>setNegativeButton<\/code> and <code>setNeutralButton<\/code> listeners respectively. At this point it is good to mention that the neutral button appears between the negative and the positive buttons.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>In our example, we will use the three listeners. If the user chooses the positive button, a new <code>Activity<\/code> will launch by enabling an <code>explicit Intent<\/code>. In contrast, if the user presses the negative button, the alert box will close and we will go back to the main activity of our app. Finally, when the user clicks the neutral button, our application will close and it will lead the user to <code>HOME<\/code>.<\/p>\n<p>Open <code>src\/com.javacodegeeks.android.alertdialogtest\/MainActivity.java<\/code> file and paste the following code.<\/p>\n<p><em><u>MainActivity.java:<\/u><\/em><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.alertdialogtest;\r\n\r\nimport android.os.Bundle;\r\nimport android.app.Activity;\r\nimport android.app.AlertDialog;\r\nimport android.content.DialogInterface;\r\nimport android.content.Intent;\r\nimport android.view.View;\r\nimport android.view.View.OnClickListener;\r\nimport android.widget.Button;\r\nimport android.widget.Toast;\r\n\r\npublic class MainActivity extends Activity {\r\n\r\n\tprivate Button mainBtn;\r\n\t\r\n\t@Override\r\n\tprotected void onCreate(Bundle savedInstanceState) {\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\t\tsetContentView(R.layout.activity_main);\r\n\t\t\r\n\t\tmainBtn = (Button) findViewById(R.id.button);\t\r\n\t\tmainBtn.setOnClickListener(new OnClickListener() {\r\n\t\t\t\r\n\t\t\t@Override\r\n\t\t\tpublic void onClick(View v) {\r\n\t\t\t\t\/\/ TODO Auto-generated method stub\r\n\t\t\t\topenAlert(v);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\t\r\n\tprivate void openAlert(View view) {\r\n\t\t AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this);\r\n\t     \r\n\t\t alertDialogBuilder.setTitle(this.getTitle()+ \" decision\");\r\n\t\t alertDialogBuilder.setMessage(\"Are you sure?\");\r\n\t\t \/\/ set positive button: Yes message\r\n\t\t alertDialogBuilder.setPositiveButton(\"Yes\",new DialogInterface.OnClickListener() {\r\n\t\t\t\tpublic void onClick(DialogInterface dialog,int id) {\r\n\t\t\t\t\t\/\/ go to a new activity of the app\r\n\t\t\t\t\tIntent positveActivity = new Intent(getApplicationContext(),\r\n                            PositiveActivity.class);\r\n\t\t            startActivity(positveActivity);\t\r\n\t\t\t\t}\r\n\t\t\t  });\r\n\t\t \/\/ set negative button: No message\r\n\t\t alertDialogBuilder.setNegativeButton(\"No\",new DialogInterface.OnClickListener() {\r\n\t\t\t\tpublic void onClick(DialogInterface dialog,int id) {\r\n\t\t\t\t\t\/\/ cancel the alert box and put a Toast to the user\r\n\t\t\t\t\tdialog.cancel();\r\n\t\t\t\t\tToast.makeText(getApplicationContext(), \"You chose a negative answer\", \r\n\t\t\t\t\t\t\tToast.LENGTH_LONG).show();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t \/\/ set neutral button: Exit the app message\r\n\t\t alertDialogBuilder.setNeutralButton(\"Exit the app\",new DialogInterface.OnClickListener() {\r\n\t\t\t\tpublic void onClick(DialogInterface dialog,int id) {\r\n\t\t\t\t\t\/\/ exit the app and go to the HOME\r\n\t\t\t\t\tMainActivity.this.finish();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t \r\n\t\t AlertDialog alertDialog = alertDialogBuilder.create();\r\n\t\t \/\/ show alert\r\n\t\t alertDialog.show();\r\n\t}\r\n\r\n}\r\n<\/pre>\n<h2>4. Crete a Custom Activity<\/h2>\n<p>We will create a new <code>Activity<\/code> for the <code>explicit Intent<\/code> of the positive answer.<\/p>\n<p>To do so right click on <code>com.javacodegeeks.android.alertdialogtest<\/code> package \u2192 New \u2192 Class. Specify the name (<code>PositiveActivity<\/code> as we defined it in the <code>MainActivity<\/code> file) and the package that will belong to and finally click Finish.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialPositiveActivity.png\"><img decoding=\"async\" class=\"aligncenter wp-image-7758 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialPositiveActivity.png\" alt=\"Android Alert Dialog - AlertDialPositiveActivity\" width=\"539\" height=\"605\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialPositiveActivity.png 539w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialPositiveActivity-267x300.png 267w\" sizes=\"(max-width: 539px) 100vw, 539px\" \/><\/a><\/p>\n<p>Open <code>src\/com.javacodegeeks.android.alertdialogtest\/PositiveActivity.java<\/code> file and paste the code below.<\/p>\n<p><em><u>PositiveActivity.java:<\/u><\/em><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.alertdialogtest;\r\n\r\nimport android.app.Activity;\r\nimport android.os.Bundle;\r\n\r\npublic class PositiveActivity extends Activity {\r\n\t@Override\r\n\t   protected void onCreate(Bundle savedInstanceState) {\r\n\t      super.onCreate(savedInstanceState);\r\n\t      setContentView(R.layout.positive_view);\r\n\t   }\r\n\r\n}\r\n<\/pre>\n<h2>5. Create the layout of the Custom Activity<\/h2>\n<p>We are going to create a simple UI for the layout of the <code>PositiveActivity<\/code> class.<\/p>\n<p>Right click on <code>res\/layout<\/code> \u2192 New \u2192 Android XML File. Then, specify the name of the file and choose <code>LinearLayout<\/code> as root element, like in the image below. Then click Finish.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialpositive_view.png\"><img decoding=\"async\" class=\"aligncenter wp-image-7759 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialpositive_view.png\" alt=\"Android Alert Dialog - AlertDialpositive_view\" width=\"459\" height=\"511\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialpositive_view.png 459w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialpositive_view-269x300.png 269w\" sizes=\"(max-width: 459px) 100vw, 459px\" \/><\/a><\/p>\n<p>Open <code>res\/layout\/positive_view.xml<\/code> and paste the following.<\/p>\n<p><em><u>positive_view.xml:<\/u><\/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:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    android:orientation=\"vertical\" &gt;\r\n\r\n    &lt;TextView\r\n        android:id=\"@+id\/textPositive\"\r\n        android:layout_width=\"fill_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:text=\"You chose a positive answer...\" \/&gt;\r\n\r\n&lt;\/LinearLayout&gt;\r\n<\/pre>\n<h2>6. Define the rules for the Custom Activity<\/h2>\n<p>We have to define the <code>PositiveActivity<\/code> activity in our <code>AndroidManifest.xml<\/code> file. In our occasion, we want <code>PositiveActivity<\/code> to leads us back to the <code>MainActivity<\/code>, so we will define the <code>MainActivity<\/code> as it&#8217;s parent <code>Activity<\/code>. For this reason <code>parentActivityName<\/code> android element is used.<\/p>\n<p>Open\u00a0<code>AndroidManifest.xml<\/code>\u00a0file and choose the xml tab. Then paste the following code.<\/p>\n<p><em><u>AndroidManifest.xml:<\/u><\/em><\/p>\n<pre class=\"brush:xml\">&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.alertdialogtest\"\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=\"19\" \/&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        &lt;activity\r\n            android:name=\"com.javacodegeeks.android.alertdialogtest.MainActivity\"\r\n            android:label=\"@string\/app_name\" &gt;\r\n            &lt;intent-filter&gt;\r\n                &lt;action android:name=\"android.intent.action.MAIN\" \/&gt;\r\n\r\n                &lt;category android:name=\"android.intent.category.LAUNCHER\" \/&gt;\r\n            &lt;\/intent-filter&gt;\r\n        &lt;\/activity&gt;\r\n        \r\n        &lt;activity\r\n         \tandroid:name=\"com.javacodegeeks.android.alertdialogtest.PositiveActivity\"\r\n         \tandroid:label=\"Positive Answer\"\r\n         \tandroid:parentActivityName=\"com.javacodegeeks.android.alertdialogtest.MainActivity\" &gt;\r\n      &lt;\/activity&gt;\r\n    &lt;\/application&gt;\r\n\r\n&lt;\/manifest&gt;\r\n<\/pre>\n<h2>7. Run the application<\/h2>\n<p>To run our application, right click on our project \u2192 Run as \u2192 Android Application. The AVD will appear with the app loaded, as you can see below.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-7761 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog1.png\" alt=\"Android Alert Dialog - AVDAlertDialog1\" width=\"256\" height=\"359\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog1.png 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog1-213x300.png 213w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>Now press the &#8220;Show Alert Box&#8221; button. An alert box will popup and the user should take a decision, in order to proceed. Notice that the buttons don&#8217;t appear in the order we set them at the <code>MainActivity.java<\/code>, because Android system defines the button order as <code>NEGATIVE - NEUTRAL - POSITIVE<\/code>.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog2.png\"><img decoding=\"async\" class=\"aligncenter wp-image-7762 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog2.png\" alt=\"Android Alert Dialog - AVDAlertDialog2\" width=\"256\" height=\"359\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog2.png 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog2-213x300.png 213w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>If we click the \u201cNo\u201d button, the alert box will be canceled and the user will go back to the <code>MainActivity<\/code> with the appearance of a <code>Toast<\/code>, as you can see in the next picture.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog4.png\"><img decoding=\"async\" class=\"aligncenter wp-image-7763 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog4.png\" alt=\"Android Alert Dialog - AVDAlertDialog4\" width=\"256\" height=\"359\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog4.png 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog4-213x300.png 213w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>When the user presses the \u201cYes\u201d button, the <code>setPositiveButton<\/code> listener will be enabled, so the <code>PositiveActivity<\/code> will launch.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog3.png\"><img decoding=\"async\" class=\"aligncenter wp-image-7764 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog3.png\" alt=\"Android Alert Dialog - AVDAlertDialog3\" width=\"256\" height=\"359\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog3.png 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog3-213x300.png 213w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>Now we can go back at the parent <code>Activity<\/code>, by pressing the button at the top left of the screen.<\/p>\n<p>Finally, if we press \u201cExit the app\u201d button, our app will close down and we will get lead to the main screen of the emulator.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog5.png\"><img decoding=\"async\" class=\"aligncenter wp-image-7774 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog5.png\" alt=\"Android Alert Dialog - AVDAlertDialog5\" width=\"256\" height=\"359\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog5.png 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDAlertDialog5-213x300.png 213w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>Of course, the user can choose and launch this application again.<\/p>\n<h2>Download Eclipse Project<\/h2>\n<p>This was an example of Android Alert Dialog. Download the Eclipse Project of this example: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AlertDialogTest.zip\">AlertDialogTest.zip<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, we feature a comprehensive Android Alert Dialog Example. Sometimes in our applications we want to alert the user for an event and\/or ask him\/her about taking a decision. For this purpose AlertDialog class can be used, where a message and one, two or three buttons are displayed in a popup window. In &hellip;<\/p>\n","protected":false},"author":11,"featured_media":1202,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[318],"tags":[512],"class_list":["post-7752","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-alertdialog","tag-alertdialog-builder"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Android Alert Dialog Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn more about Android? Then check out our detailed example on Android Alert Dialog! We are going to show an AlertDialog with three different buttons, where each one leads to a different action. We will use the following tools in a Windows 64-bit platform: JDK 1.7, Eclipse 4.2 Juno, Android SDK 4.4\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android Alert Dialog Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about Android? Then check out our detailed example on Android Alert Dialog! We are going to show an AlertDialog with three different buttons, where each one leads to a different action. We will use the following tools in a Windows 64-bit platform: JDK 1.7, Eclipse 4.2 Juno, Android SDK 4.4\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-12-26T11:53:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-06-12T09:54:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/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=\"Katerina Zamani\" \/>\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=\"Katerina Zamani\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/\"},\"author\":{\"name\":\"Katerina Zamani\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/94be714b6b9a82bb855c0d370c319673\"},\"headline\":\"Android Alert Dialog Example\",\"datePublished\":\"2013-12-26T11:53:01+00:00\",\"dateModified\":\"2018-06-12T09:54:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/\"},\"wordCount\":788,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"keywords\":[\"AlertDialog.Builder\"],\"articleSection\":[\"AlertDialog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/\",\"name\":\"Android Alert Dialog Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"datePublished\":\"2013-12-26T11:53:01+00:00\",\"dateModified\":\"2018-06-12T09:54:27+00:00\",\"description\":\"Interested to learn more about Android? Then check out our detailed example on Android Alert Dialog! We are going to show an AlertDialog with three different buttons, where each one leads to a different action. We will use the following tools in a Windows 64-bit platform: JDK 1.7, Eclipse 4.2 Juno, Android SDK 4.4\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"core\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"ui\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/ui\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"AlertDialog\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/ui\/alertdialog\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"Android Alert Dialog Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/94be714b6b9a82bb855c0d370c319673\",\"name\":\"Katerina Zamani\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Katerina-Zamani-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Katerina-Zamani-96x96.jpg\",\"caption\":\"Katerina Zamani\"},\"description\":\"Katerina has graduated from the Department of Informatics and Telecommunications in National and Kapodistrian University of Athens (NKUA) and she attends MSc courses in Advanced Information Systems at the same department. Currently, her main academic interests focus on web applications, mobile development, software engineering, databases and telecommunications.\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/katerina-zamani\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android Alert Dialog Example - Java Code Geeks","description":"Interested to learn more about Android? Then check out our detailed example on Android Alert Dialog! We are going to show an AlertDialog with three different buttons, where each one leads to a different action. We will use the following tools in a Windows 64-bit platform: JDK 1.7, Eclipse 4.2 Juno, Android SDK 4.4","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:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/","og_locale":"en_US","og_type":"article","og_title":"Android Alert Dialog Example - Java Code Geeks","og_description":"Interested to learn more about Android? Then check out our detailed example on Android Alert Dialog! We are going to show an AlertDialog with three different buttons, where each one leads to a different action. We will use the following tools in a Windows 64-bit platform: JDK 1.7, Eclipse 4.2 Juno, Android SDK 4.4","og_url":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-12-26T11:53:01+00:00","article_modified_time":"2018-06-12T09:54:27+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","type":"image\/jpeg"}],"author":"Katerina Zamani","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Katerina Zamani","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/"},"author":{"name":"Katerina Zamani","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/94be714b6b9a82bb855c0d370c319673"},"headline":"Android Alert Dialog Example","datePublished":"2013-12-26T11:53:01+00:00","dateModified":"2018-06-12T09:54:27+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/"},"wordCount":788,"commentCount":1,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","keywords":["AlertDialog.Builder"],"articleSection":["AlertDialog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/","url":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/","name":"Android Alert Dialog Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","datePublished":"2013-12-26T11:53:01+00:00","dateModified":"2018-06-12T09:54:27+00:00","description":"Interested to learn more about Android? Then check out our detailed example on Android Alert Dialog! We are going to show an AlertDialog with three different buttons, where each one leads to a different action. We will use the following tools in a Windows 64-bit platform: JDK 1.7, Eclipse 4.2 Juno, Android SDK 4.4","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Android","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/"},{"@type":"ListItem","position":3,"name":"core","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/"},{"@type":"ListItem","position":4,"name":"ui","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/ui\/"},{"@type":"ListItem","position":5,"name":"AlertDialog","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/ui\/alertdialog\/"},{"@type":"ListItem","position":6,"name":"Android Alert Dialog Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/94be714b6b9a82bb855c0d370c319673","name":"Katerina Zamani","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Katerina-Zamani-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/Katerina-Zamani-96x96.jpg","caption":"Katerina Zamani"},"description":"Katerina has graduated from the Department of Informatics and Telecommunications in National and Kapodistrian University of Athens (NKUA) and she attends MSc courses in Advanced Information Systems at the same department. Currently, her main academic interests focus on web applications, mobile development, software engineering, databases and telecommunications.","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/katerina-zamani\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/7752","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=7752"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/7752\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1202"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=7752"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=7752"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=7752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}