{"id":7565,"date":"2013-12-16T12:00:00","date_gmt":"2013-12-16T10:00:00","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=7565"},"modified":"2013-12-16T00:12:43","modified_gmt":"2013-12-15T22:12:43","slug":"android-notifications-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/","title":{"rendered":"Android Notifications Example"},"content":{"rendered":"<p><a href=\"http:\/\/developer.android.com\/guide\/topics\/ui\/notifiers\/notifications.html\" target=\"_blank\"><code>Notification<\/code><\/a> is a message that doesn&#8217;t appear inside the main UI of the app but as an icon in the notification area, including more details in the notification drawer. The aim of the notifications is to keep the user informed about events or alerts in a more persistent method, as the user can view them at any time. In this tutorial, we will create two different <code>Notifications<\/code>, the first one with normal view and the second one with big view, using <code>explicit<\/code> and <code>implicit<\/code> <code>Intents<\/code> respectively.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<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>Specify the name of the application, the project and the package. Then, choose as \u201cMinimum Required SDK\u201d the API 17 or larger and click Next.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotifProject1.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotifProject1.png\" alt=\"NotifProject1\" width=\"511\" height=\"522\" class=\"alignnone size-full wp-image-7568\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotifProject1.png 511w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotifProject1-293x300.png 293w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotifProject1-42x42.png 42w\" sizes=\"(max-width: 511px) 100vw, 511px\" \/><\/a><\/p>\n<p>In the next window, the \u201cCreate Activity\u201d option should be checked. 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\/NotifProject2.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotifProject2.png\" alt=\"NotifProject2\" width=\"511\" height=\"522\" class=\"alignnone size-full wp-image-7569\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotifProject2.png 511w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotifProject2-293x300.png 293w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotifProject2-42x42.png 42w\" sizes=\"(max-width: 511px) 100vw, 511px\" \/><\/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 click Next.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject3.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject3.png\" alt=\"createProject3!\" width=\"563\" height=\"572\" class=\"alignnone size-full wp-image-7274\" 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 press Next.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject4.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject4.png\" alt=\"createProject4!\" width=\"563\" height=\"572\" class=\"alignnone size-full wp-image-7275\" 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>You have to 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\u00a0folder<\/code>. Finally, press Finish.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject5.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/createProject5.png\" alt=\"createProject5!\" width=\"522\" height=\"555\" class=\"alignnone size-full wp-image-7276\" 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>Now that the project is created, you can see the final structure of the project in the image below.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotifProjectFull.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotifProjectFull.png\" alt=\"NotifProjectFull\" width=\"343\" height=\"585\" class=\"alignnone size-full wp-image-7570\" \/><\/a><\/p>\n<h2>2. Create the layout of the Main Activity<\/h2>\n<p>As we said above, we want to define two different <code>Notifications<\/code>, so we are going to add two <code>Buttons<\/code>, that each one enables the respective <code>notification<\/code>.<\/p>\n<p>Open <code>res\/layout\/activity_main.xml<\/code> file, go to the xml tab and paste the following code.<\/p>\n<p><em><u>activity_main.xml:<\/u><\/em><\/p>\n<pre class=\"brush:xml\">\r\n&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;Button \r\n        android:id=\"@+id\/notificationOne\"\r\n   \t\tandroid:layout_width=\"fill_parent\"\r\n   \t\tandroid:layout_height=\"wrap_content\"\r\n   \t\tandroid:text=\"start notification one\" \/&gt;\r\n\r\n   &lt;Button\r\n       android:id=\"@+id\/notificationTwo\"\r\n       android:layout_width=\"fill_parent\"\r\n       android:layout_height=\"wrap_content\"\r\n       android:layout_alignParentLeft=\"true\"\r\n       android:layout_alignParentTop=\"true\"\r\n       android:layout_marginTop=\"60dp\"\r\n       android:text=\"start notification two\" \/&gt;\r\n\r\n&lt;\/RelativeLayout&gt;\r\n<\/pre>\n<h2>3. Code the Main Activity<\/h2>\n<p>To facilitate the display of layout and the control of the actions of notifications, a <a href=\"http:\/\/developer.android.com\/reference\/android\/support\/v4\/app\/NotificationCompat.Builder.html\" target=\"_blank\"><code>NotificationCompat.Builder<\/code><\/a> object is used. Every <a href=\"http:\/\/developer.android.com\/reference\/android\/app\/Notification.html\" target=\"_blank\"><code>Notification<\/code><\/a> object have to contain:<\/p>\n<ul>\n<li>a small icon<\/li>\n<li>a title<\/li>\n<li>a detail text<\/li>\n<\/ul>\n<p>set by <code>setSmallIcon()<\/code>, <code>setContentTitle()<\/code> and <code>setContentText()<\/code> respectively. There are also more layout contents that can be used in a notification, but there are optional. For a big view notification appearance, except the contents of the normal view, a <a href=\"http:\/\/developer.android.com\/reference\/android\/support\/v4\/app\/NotificationCompat.Builder.html#setStyle(android.support.v4.app.NotificationCompat.Style)\" target=\"_blank\"><code>Builder.setStyle()<\/code><\/a> ought to be added.<\/p>\n<p>A notification action connects a notification with an <code>Activity<\/code> in the application, when the user clicks that notification. A notification can provide multiple actions but at least one should be added, although it is optional. To define the action we should use a <code>PentingIntent<\/code>, which contains an <code>Intent<\/code> that starts the <code>Activity<\/code> in the app. <\/p>\n<p>In our example, we want to remove the notification every time the user enables it. We are going to use two different ways to do such thing. For the notification with the <code>explicit intent<\/code>, we will use the <code>cancel(notificationId)<\/code> method in the <code>Activity<\/code> of that <code>Intent<\/code>, so the notification will be removed when the <code>Activity<\/code> is displayed. For the notification with the <code>implicit intent<\/code>, the <code>setAutoCancel()<\/code> method is called when the user clicks the notification text in the notification drawer.<\/p>\n<p>Open <code>src\/com.javacodegeeks.android.notificationstest\/MainActivity.java<\/code> file and paste the following code.<\/p>\n<p><em><u>MainActivity.java:<\/u><\/em><\/p>\n<pre class=\"brush:java\">\r\npackage com.javacodegeeks.android.notificationstest;\r\n\r\nimport android.net.Uri;\r\nimport android.os.Bundle;\r\nimport android.app.Activity;\r\nimport android.app.NotificationManager;\r\nimport android.app.PendingIntent;\r\nimport android.app.TaskStackBuilder;\r\nimport android.content.Context;\r\nimport android.content.Intent;\r\nimport android.support.v4.app.NotificationCompat;\r\nimport android.view.View;\r\nimport android.widget.Button;\r\n\r\npublic class MainActivity extends Activity {\r\n   private NotificationManager myNotificationManager;\r\n   private int notificationIdOne = 111;\r\n   private int notificationIdTwo = 112;\r\n   private int numMessagesOne = 0;\r\n   private int numMessagesTwo = 0;\r\n\r\n   protected void onCreate(Bundle savedInstanceState) {\r\n      super.onCreate(savedInstanceState);\r\n      setContentView(R.layout.activity_main);\r\n\r\n      Button notOneBtn = (Button) findViewById(R.id.notificationOne);\r\n      notOneBtn.setOnClickListener(new View.OnClickListener() {\r\n         public void onClick(View view) {\r\n            displayNotificationOne();\r\n         }\r\n      });\r\n   \r\n      Button notTwoBtn = (Button) findViewById(R.id.notificationTwo);\r\n      notTwoBtn.setOnClickListener(new View.OnClickListener() {\r\n         public void onClick(View view) {\r\n            displayNotificationTwo();\r\n         }\r\n      });\r\n  \r\n   }\r\n   \r\n   protected void displayNotificationOne() {\r\n\r\n      \/\/ Invoking the default notification service\r\n      NotificationCompat.Builder  mBuilder = new NotificationCompat.Builder(this);\t\r\n \r\n      mBuilder.setContentTitle(\"New Message with explicit intent\");\r\n      mBuilder.setContentText(\"New message from javacodegeeks received\");\r\n      mBuilder.setTicker(\"Explicit: New Message Received!\");\r\n      mBuilder.setSmallIcon(R.drawable.ic_launcher);\r\n\r\n      \/\/ Increase notification number every time a new notification arrives \r\n      mBuilder.setNumber(++numMessagesOne);\r\n      \r\n      \/\/ Creates an explicit intent for an Activity in your app \r\n      Intent resultIntent = new Intent(this, NotificationOne.class);\r\n      resultIntent.putExtra(\"notificationId\", notificationIdOne);\r\n\r\n      \/\/This ensures that navigating backward from the Activity leads out of the app to Home page\r\n      TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);\r\n\r\n      \/\/ Adds the back stack for the Intent\r\n      stackBuilder.addParentStack(NotificationOne.class);\r\n\r\n      \/\/ Adds the Intent that starts the Activity to the top of the stack\r\n      stackBuilder.addNextIntent(resultIntent);\r\n      PendingIntent resultPendingIntent =\r\n         stackBuilder.getPendingIntent(\r\n            0,\r\n            PendingIntent.FLAG_ONE_SHOT \/\/can only be used once\r\n         );\r\n      \/\/ start the activity when the user clicks the notification text\r\n      mBuilder.setContentIntent(resultPendingIntent);\r\n\r\n      myNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);\r\n\r\n      \/\/ pass the Notification object to the system \r\n      myNotificationManager.notify(notificationIdOne, mBuilder.build());\r\n   }\r\n\r\n   protected void displayNotificationTwo() {\r\n      \/\/ Invoking the default notification service\r\n      NotificationCompat.Builder  mBuilder = new NotificationCompat.Builder(this);\t\r\n\r\n      mBuilder.setContentTitle(\"New Message with implicit intent\");\r\n      mBuilder.setContentText(\"New message from javacodegeeks received...\");\r\n      mBuilder.setTicker(\"Implicit: New Message Received!\");\r\n      mBuilder.setSmallIcon(R.drawable.ic_launcher);\r\n      \r\n      NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();\r\n\r\n       String[] events = new String[3];\r\n       events[0] = new String(\"1) Message for implicit intent\");\r\n       events[1] = new String(\"2) big view Notification\");\r\n       events[2] = new String(\"3) from javacodegeeks!\");\r\n\r\n       \/\/ Sets a title for the Inbox style big view\r\n       inboxStyle.setBigContentTitle(\"More Details:\");\r\n       \/\/ Moves events into the big view\r\n       for (int i=0; i &lt; events.length; i++) {\r\n          inboxStyle.addLine(events[i]);\r\n       }\r\n       mBuilder.setStyle(inboxStyle);\r\n        \r\n      \/\/ Increase notification number every time a new notification arrives\r\n      mBuilder.setNumber(++numMessagesTwo);\r\n\r\n      \/\/ When the user presses the notification, it is auto-removed\r\n      mBuilder.setAutoCancel(true);\r\n      \r\n      \/\/ Creates an implicit intent \r\n      Intent resultIntent = new Intent(\"com.example.javacodegeeks.TEL_INTENT\", \r\n    \t\t  Uri.parse(\"tel:123456789\"));\r\n      resultIntent.putExtra(\"from\", \"javacodegeeks\");\r\n      \r\n      TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);\r\n      stackBuilder.addParentStack(NotificationTwo.class);\r\n\r\n      stackBuilder.addNextIntent(resultIntent);\r\n      PendingIntent resultPendingIntent =\r\n         stackBuilder.getPendingIntent(\r\n            0,\r\n            PendingIntent.FLAG_ONE_SHOT\r\n         );\r\n      mBuilder.setContentIntent(resultPendingIntent);\r\n\r\n      myNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);\r\n\r\n      myNotificationManager.notify(notificationIdTwo, mBuilder.build());   \r\n\r\n   }\r\n   \r\n}\r\n<\/pre>\n<h2>4. Create the Activity of Notification Action <\/h2>\n<p>We want to make the <code>Activity<\/code> of the notification, that will be started when the user clicks it.<br \/>\nWe are going to make two different <code>Activities<\/code> for each notification, so we have to create two different files.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>For the first file that concerns the <code>explicit Intent<\/code>, right click on <code>src\/com.javacodegeeks.android.notificationstest<\/code> package \u2192 New \u2192 Class. <\/p>\n<p>Specify the name of the class and press Finish.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotificationOneCreate.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotificationOneCreate.png\" alt=\"NotificationOneCreate\" width=\"536\" height=\"600\" class=\"alignnone size-full wp-image-7575\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotificationOneCreate.png 536w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotificationOneCreate-268x300.png 268w\" sizes=\"(max-width: 536px) 100vw, 536px\" \/><\/a><\/p>\n<p>Open <code>src\/com.javacodegeeks.android.notificationstest\/NotificationOne.java<\/code> file and paste the following.<\/p>\n<p><em><u>NotificationOne.java:<\/u><\/em><\/p>\n<pre class=\"brush:java; highlight:[28,29,31];\">\r\npackage com.javacodegeeks.android.notificationstest;\r\n\r\nimport android.os.Bundle;\r\nimport android.widget.TextView;\r\nimport android.app.Activity;\r\nimport android.app.NotificationManager;\r\nimport android.content.Context;\r\n\r\npublic class NotificationOne extends Activity {\r\n\t@Override\r\n\t   public void onCreate(Bundle savedInstanceState)\r\n\t   {\r\n\t      super.onCreate(savedInstanceState);\r\n\t      setContentView(R.layout.notification_one);\r\n\t      CharSequence s = \"Inside the activity of Notification one \";\r\n\t      int id=0;\r\n\t      \r\n\t      Bundle extras = getIntent().getExtras();\r\n\t\t\tif (extras == null) {\r\n\t\t\t\ts = \"error\";\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tid = extras.getInt(\"notificationId\");\r\n\t\t\t}\r\n\t\t\tTextView t = (TextView) findViewById(R.id.text1);\r\n\t\t\ts = s+\"with id = \"+id;\r\n\t\t\tt.setText(s);\r\n\t\t\tNotificationManager myNotificationManager = \r\n\t\t\t\t\t(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);\r\n\t\t\t\r\n\t\t\t\/\/ remove the notification with the specific id\r\n\t\t\tmyNotificationManager.cancel(id);\r\n\t   }\r\n\r\n}\r\n<\/pre>\n<p>At this point, we will remove the notification from the notification bar, as you can notice in the highlighted lines.<\/p>\n<p>For the second file that concerns the <code>implicit Intent<\/code>, we will make a similar procedure. Right click on <code>src\/com.javacodegeeks.android.notificationstest<\/code> package \u2192 New \u2192 Class. Then, specify the name of the class and press Finish. We will name it <code>NotificationTwo.java<\/code>.<\/p>\n<p>Now, open <code>src\/com.javacodegeeks.android.notificationstest\/NotificationTwo.java<\/code> file and paste the following.<\/p>\n<p><em><u>NotificationTwo.java:<\/u><\/em><\/p>\n<pre class=\"brush:java\">\r\npackage com.javacodegeeks.android.notificationstest;\r\n\r\nimport android.app.Activity;\r\nimport android.net.Uri;\r\nimport android.os.Bundle;\r\nimport android.widget.TextView;\r\n\r\npublic class NotificationTwo extends Activity {\r\n\r\n\t@Override\r\n\t   public void onCreate(Bundle savedInstanceState) {\r\n\t      super.onCreate(savedInstanceState);\r\n\t      setContentView(R.layout.notification_two);\r\n\r\n\t      String output = \"Inside the activity of Notification two: \";\r\n\t      TextView dataIntent = (TextView) findViewById(R.id.text2);\r\n\t    \r\n\t      \/\/ take the data and the extras of the intent\r\n\t      Uri url = getIntent().getData();\r\n\t      Bundle extras = getIntent().getExtras();\r\n\t      \r\n\t      output = output + url.toString();\r\n\t      \/\/ if there are extras, add them to the output string\r\n\t      if(extras != null){\r\n\t    \t  output = output + \" from \" +extras.getString(\"from\");\r\n\t\t\t \r\n\t      }\r\n\t      dataIntent.setText(output);\r\n\t   }\r\n\r\n}\r\n<\/pre>\n<p>At this situation, we don&#8217;t do anything for canceling the notification, because we already did it in the <code>displayNotificationTwo()<\/code> function of <code>MainActivity.java<\/code> file, by using <code>setAutoCancel()<\/code> method.<\/p>\n<h2>5. Create the layouts of Notification Actions<\/h2>\n<p>We need to create layouts, which will be displayed when the <code>Activity<\/code> of each notification action starts. <\/p>\n<p>For the <code>NotificationOne.java<\/code> we will use <code>notification_one<\/code> layout as we defined in the file, so right click on <code>res\/layout<\/code> \u2192 New \u2192 Android XML File. Specify the name and choose <code>LinearLayout<\/code> as root element.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/notification_oneLayout.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/notification_oneLayout.png\" alt=\"notification_oneLayout\" width=\"458\" height=\"561\" class=\"alignnone size-full wp-image-7578\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/notification_oneLayout.png 458w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/notification_oneLayout-244x300.png 244w\" sizes=\"(max-width: 458px) 100vw, 458px\" \/><\/a><\/p>\n<p>Then open <code>res\/layout\/notification_one.xml<\/code> file at the xml tab and paste the following.<\/p>\n<p><em><u>notification_one.xml:<\/u><\/em><\/p>\n<pre class=\"brush:xml\">\r\n&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=\"fill_parent\"\r\n    android:layout_height=\"fill_parent\"\r\n    android:orientation=\"vertical\" &gt;\r\n    \r\n     &lt;TextView\r\n        android:id=\"@+id\/text1\"\r\n   \t\tandroid:layout_width=\"fill_parent\"\r\n   \t\tandroid:layout_height=\"fill_parent\" \/&gt;\r\n\r\n&lt;\/LinearLayout&gt;\r\n<\/pre>\n<p>In the same way, we are going to make the layout for the <code>NotificationTwo.java<\/code> file. <\/p>\n<p>Right click on <code>res\/layout<\/code> \u2192 New \u2192 Android XML File. Specify the name and choose <code>LinearLayout<\/code> as root element. Lets name it <code>notification_two.xml<\/code>, as we defined it in the <code>Activity<\/code> that belongs to. <\/p>\n<p>Then open <code>res\/layout\/notification_two.xml<\/code> file at the xml tab and paste the following.<\/p>\n<p><em><u>notification_two.xml:<\/u><\/em><\/p>\n<pre class=\"brush:xml\">\r\n&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=\"fill_parent\"\r\n    android:layout_height=\"fill_parent\"\r\n    android:orientation=\"vertical\" &gt;\r\n    \r\n    &lt;TextView\r\n        android:id=\"@+id\/text2\"\r\n        android:layout_width=\"fill_parent\"\r\n        android:layout_height=\"fill_parent\" \/&gt;\r\n\r\n&lt;\/LinearLayout&gt;\r\n<\/pre>\n<h2>6. Define the rules for the Notification Activities<\/h2>\n<p>We are going to use <code>&lt;meta-data&gt;<\/code> element, in order to define the parent of the <code>NotificationOne<\/code> and <code>NotificationTwo<\/code> <code>Activities<\/code>. <code>&lt;meta-data&gt;<\/code> element is additional data, that can be provided to the parent component. So, we will fill in the elements with the appropriate values. For this reason, we will put <code>android.support.PARENT_ACTIVITY<\/code> in the <code>android:name<\/code>, and in the <code>android:value<\/code> we will put the name of the parent <code>Activity<\/code>. Also, we should define the rules for the <code>implicit Intent<\/code> that we use in the appropriate <code>&lt;activity&gt;<\/code> element.<\/p>\n<p>Open <code>AndroidManifest.xml<\/code> file 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\">\r\n&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.notificationstest\"\r\n    android:versionCode=\"1\"\r\n    android:versionName=\"1.0\" &gt;\r\n\r\n    &lt;uses-sdk\r\n        android:minSdkVersion=\"17\"\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.notificationstest.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 android:name=\".NotificationOne\"\r\n             android:label=\"Details of Notification One\"\r\n             android:parentActivityName=\".MainActivity\"&gt;\r\n        \t&lt;meta-data\r\n        \t\tandroid:name=\"android.support.PARENT_ACTIVITY\"\r\n        \t\tandroid:value=\".MainActivity\"\/&gt;\r\n        &lt;\/activity&gt;\r\n        &lt;activity \r\n            android:name=\".NotificationTwo\" \r\n            android:label=\"Details of Notification Two\"\r\n            android:parentActivityName=\".MainActivity\"&gt;\r\n       \r\n           &lt;intent-filter&gt;\r\n              &lt;action android:name=\"com.example.javacodegeeks.TEL_INTENT\" \/&gt;\r\n              &lt;category android:name=\"android.intent.category.DEFAULT\" \/&gt;\r\n              &lt;data android:scheme=\"tel\" \/&gt;\r\n           &lt;\/intent-filter&gt;\r\n           &lt;meta-data\r\n        \t\tandroid:name=\"android.support.PARENT_ACTIVITY\"\r\n        \t\tandroid:value=\".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. <\/p>\n<p>When we press the &#8220;start notification one&#8221; button, a new notification is created and it&#8217;s <code>Ticker<\/code> appears.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest1.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest1.png\" alt=\"AVDNotificationsTest1\" width=\"256\" height=\"359\" class=\"alignnone size-full wp-image-7584\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest1.png 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest1-213x300.png 213w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>If we drag in the top of the screen and go to the notification drawer, we will see the normal view of the notification, as shown in the picture below.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest2_1.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest2_1.png\" alt=\"AVDNotificationsTest2_1\" width=\"256\" height=\"359\" class=\"alignnone size-full wp-image-7586\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest2_1.png 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest2_1-213x300.png 213w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>If the user presses the notification, the <code>Activity<\/code> <code>NotificationOne<\/code> will be called and the notification will be removed from the notification bar. Notice that there is a button that leads back to the <code>MainActivity<\/code>, while we defined it as the parent activity for the <code>NotificationOne<\/code>.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest3.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest3.png\" alt=\"AVDNotificationsTest3\" width=\"256\" height=\"359\" class=\"alignnone size-full wp-image-7587\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest3.png 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest3-213x300.png 213w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>Now, press the &#8220;start notification two&#8221; button and notice the appearance of the notification <code>Ticker<\/code> in the image below. <\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest4.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest4.png\" alt=\"AVDNotificationsTest4\" width=\"256\" height=\"359\" class=\"alignnone size-full wp-image-7588\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest4.png 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest4-213x300.png 213w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>That means that the second notification with the big view is created, as you can see in the next picture.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest5_1.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest5_1.png\" alt=\"AVDNotificationsTest5_1\" width=\"256\" height=\"359\" class=\"alignnone size-full wp-image-7589\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest5_1.png 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest5_1-213x300.png 213w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>If we press it, the notification will be removed because of <code>setAutoCancel()<\/code> method, and the <code>NotificationTwo<\/code> <code>Activity<\/code> will be called. There is a button too, that goes back to the parent activity as we defined in the <code>AndroidManifest.xml<\/code> file.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest6.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest6.png\" alt=\"AVDNotificationsTest6\" width=\"256\" height=\"359\" class=\"alignnone size-full wp-image-7590\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest6.png 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/AVDNotificationsTest6-213x300.png 213w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<h2>Download Eclipse Project<\/h2>\n<p>This was an example of Notifications in Android. Download the Eclipse Project of this example: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/12\/NotificationsTest.zip\">NotificationsTest.zip<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Notification is a message that doesn&#8217;t appear inside the main UI of the app but as an icon in the notification area, including more details in the notification drawer. The aim of the notifications is to keep the user informed about events or alerts in a more persistent method, as the user can view them &hellip;<\/p>\n","protected":false},"author":11,"featured_media":1202,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[501],"tags":[502,503],"class_list":["post-7565","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-notifications","tag-notificationcompat-builder","tag-pentingintent"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Android Notifications Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Notification is a message that doesn&#039;t appear inside the main UI of the app but as an icon in the notification area, including more details in the\" \/>\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\/notifications\/android-notifications-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android Notifications Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Notification is a message that doesn&#039;t appear inside the main UI of the app but as an icon in the notification area, including more details in the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/\" \/>\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-16T10:00:00+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=\"11 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\/notifications\/android-notifications-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/\"},\"author\":{\"name\":\"Katerina Zamani\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/94be714b6b9a82bb855c0d370c319673\"},\"headline\":\"Android Notifications Example\",\"datePublished\":\"2013-12-16T10:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/\"},\"wordCount\":1094,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"keywords\":[\"NotificationCompat.Builder\",\"PentingIntent\"],\"articleSection\":[\"Notifications\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/\",\"name\":\"Android Notifications Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"datePublished\":\"2013-12-16T10:00:00+00:00\",\"description\":\"Notification is a message that doesn't appear inside the main UI of the app but as an icon in the notification area, including more details in the\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/#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\/notifications\/android-notifications-example\/#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\":\"Notifications\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/ui\/notifications\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"Android Notifications 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 Notifications Example - Java Code Geeks","description":"Notification is a message that doesn't appear inside the main UI of the app but as an icon in the notification area, including more details in the","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\/notifications\/android-notifications-example\/","og_locale":"en_US","og_type":"article","og_title":"Android Notifications Example - Java Code Geeks","og_description":"Notification is a message that doesn't appear inside the main UI of the app but as an icon in the notification area, including more details in the","og_url":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-12-16T10:00:00+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":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/"},"author":{"name":"Katerina Zamani","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/94be714b6b9a82bb855c0d370c319673"},"headline":"Android Notifications Example","datePublished":"2013-12-16T10:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/"},"wordCount":1094,"commentCount":3,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","keywords":["NotificationCompat.Builder","PentingIntent"],"articleSection":["Notifications"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/","url":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/","name":"Android Notifications Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","datePublished":"2013-12-16T10:00:00+00:00","description":"Notification is a message that doesn't appear inside the main UI of the app but as an icon in the notification area, including more details in the","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/notifications\/android-notifications-example\/#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\/notifications\/android-notifications-example\/#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":"Notifications","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/ui\/notifications\/"},{"@type":"ListItem","position":6,"name":"Android Notifications 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\/7565","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=7565"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/7565\/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=7565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=7565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=7565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}