{"id":18095,"date":"2013-10-15T19:00:44","date_gmt":"2013-10-15T16:00:44","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=18095"},"modified":"2013-10-15T09:27:27","modified_gmt":"2013-10-15T06:27:27","slug":"android-notificationlistenerservice-example","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-example.html","title":{"rendered":"Android NotificationListenerService Example"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p><a href=\"http:\/\/developer.android.com\/reference\/android\/service\/notification\/NotificationListenerService.html\">NotificationListenerService<\/a> is introduced in Android 4.3 (API 18). It allows an application to receive information about notifications as it creates or removes. NotificationListenerService class is derived from the <a href=\"http:\/\/developer.android.com\/reference\/android\/app\/Service.html\">Service<\/a> class. It has two abstract methods namely 1. onNotificationPosted 2. onNotificationRemoved.<\/p>\n<p>To use NotificationListenerService, we need to create a java file which extends NotificationListenerService and implement two callback methods. Both methods have a parameter named &#8220;sbn&#8221;, which is an object of <a href=\"http:\/\/developer.android.com\/reference\/android\/service\/notification\/StatusBarNotification.html\">StatusBarNotification<\/a> class. StatusBarNotification provides necessary information about Notifications.<\/p>\n<p>NotificationListenerService provides facility to fetch active notifications using getActiveNotifications and also provides a feature to remove notifications using cancelAllNotifications.<\/p>\n<h2>Useful Methods<\/h2>\n<ol>\n<li><code>NotificationListenerService<br \/>\nonNotificationPosted()<br \/>\nonNotificationRemoved()<br \/>\ncancelAllNotifications()<br \/>\ngetActiveNotifications()<\/code><\/li>\n<li><code>StatusBarNotification<br \/>\ngetId()<br \/>\ngetNotification()<br \/>\ngetPackageName()<br \/>\ngetPostTime()<br \/>\nisClearable()<br \/>\nisOngoing()<\/code><\/li>\n<\/ol>\n<p><strong>Note:<\/strong> User require to enable notification permission from\u00a0&#8220;Settings &gt; Security &gt; Notification access&#8221;.<\/p>\n<h2>Source Code of NotificationListenerService<\/h2>\n<p>Worth to see the source code, If you hare curious. It has two java files and two AIDL files: <a href=\"https:\/\/android.googlesource.com\/platform\/frameworks\/base\/+\/refs\/heads\/master\/core\/java\/android\/service\/notification\">https:\/\/android.googlesource.com\/platform\/frameworks\/base\/+\/refs\/heads\/master\/core\/java\/android\/service\/notification<\/a><\/p>\n<h2>Example<\/h2>\n<p>This is simple example of NotificationListenerService, It has simple UI contain three buttons and one textview.<\/p>\n<ul>\n<li>Create Notification &#8211; It will create simple notification so that we can test onNotificationPosted event<\/li>\n<li>Clear All Notification &#8211; It will create all notification in notificationbar<\/li>\n<li>List of Notification &#8211; It will display notification list in textview<\/li>\n<li>TextView &#8211; display notification events and list of notification.<\/li>\n<\/ul>\n<p>This example has Activity, Service and BroadcastReceiver. BroadcastReceiver used for communication between activity and service. We can&#8217;t access cancelAllNotifications() and getActiveNotifications() methods from activity directly so I use BroadcastReceivers.<\/p>\n<h2>Screenshots<\/h2>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/device-2013-08-02-103019.png\"><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/device-2013-08-02-103019.png\" width=\"238\" height=\"400\" border=\"0\" \/><\/a> <a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/device-2013-08-02-103059.png\"><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/device-2013-08-02-103059.png\" width=\"238\" height=\"400\" border=\"0\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/device-2013-07-31-113701.png\"><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/device-2013-07-31-113701.png\" width=\"238\" height=\"400\" border=\"0\" \/><\/a> <a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/device-2013-07-31-113720.png\"><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/device-2013-07-31-113720.png\" width=\"238\" height=\"400\" border=\"0\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-07-31-at-11.31.40-AM.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-07-31-at-11.31.40-AM-1024x270.png\" alt=\"Screen Shot 2013-07-31 at 11.31.40 AM\" width=\"624\" height=\"125\" class=\"aligncenter size-large wp-image-18115\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-07-31-at-11.36.04-AM.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Screen-Shot-2013-07-31-at-11.36.04-AM-1024x263.png\" alt=\"Screen Shot 2013-07-31 at 11.36.04 AM\" width=\"624\" height=\"120\" class=\"aligncenter size-large wp-image-18116\" \/><\/a><\/p>\n<h2>Source Code<\/h2>\n<p><strong>1. MainActivity.java<\/strong><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\" brush:java\">package com.kpbird.nlsexample;\r\n\r\nimport android.app.Activity;\r\nimport android.app.NotificationManager;\r\nimport android.content.BroadcastReceiver;\r\nimport android.content.Context;\r\nimport android.content.Intent;\r\nimport android.content.IntentFilter;\r\nimport android.os.Bundle;\r\nimport android.support.v4.app.NotificationCompat;\r\nimport android.view.View;\r\nimport android.widget.TextView;\r\n\r\npublic class MainActivity extends Activity {\r\n\r\n    private TextView txtView;\r\n    private NotificationReceiver nReceiver;\r\n\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_main);\r\n        txtView = (TextView) findViewById(R.id.textView);\r\n        nReceiver = new NotificationReceiver();\r\n        IntentFilter filter = new IntentFilter();\r\n        filter.addAction(\"com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE\");\r\n        registerReceiver(nReceiver,filter);\r\n    }\r\n\r\n    @Override\r\n    protected void onDestroy() {\r\n        super.onDestroy();\r\n        unregisterReceiver(nReceiver);\r\n    }\r\n\r\n    public void buttonClicked(View v){\r\n\r\n        if(v.getId() == R.id.btnCreateNotify){\r\n            NotificationManager nManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);\r\n            NotificationCompat.Builder ncomp = new NotificationCompat.Builder(this);\r\n            ncomp.setContentTitle(\"My Notification\");\r\n            ncomp.setContentText(\"Notification Listener Service Example\");\r\n            ncomp.setTicker(\"Notification Listener Service Example\");\r\n            ncomp.setSmallIcon(R.drawable.ic_launcher);\r\n            ncomp.setAutoCancel(true);\r\n            nManager.notify((int)System.currentTimeMillis(),ncomp.build());\r\n        }\r\n        else if(v.getId() == R.id.btnClearNotify){\r\n            Intent i = new Intent(\"com.kpbird.nlsexample.NOTIFICATION_LISTENER_SERVICE_EXAMPLE\");\r\n            i.putExtra(\"command\",\"clearall\");\r\n            sendBroadcast(i);\r\n        }\r\n        else if(v.getId() == R.id.btnListNotify){\r\n            Intent i = new Intent(\"com.kpbird.nlsexample.NOTIFICATION_LISTENER_SERVICE_EXAMPLE\");\r\n            i.putExtra(\"command\",\"list\");\r\n            sendBroadcast(i);\r\n        }\r\n\r\n    }\r\n\r\n    class NotificationReceiver extends BroadcastReceiver{\r\n\r\n        @Override\r\n        public void onReceive(Context context, Intent intent) {\r\n            String temp = intent.getStringExtra(\"notification_event\") + \"n\" + txtView.getText();\r\n            txtView.setText(temp);\r\n        }\r\n    }\r\n\r\n}<\/pre>\n<p><strong>2. NLService.java<\/strong><\/p>\n<pre class=\" brush:java\">package com.kpbird.nlsexample;\r\n\r\nimport android.content.BroadcastReceiver;\r\nimport android.content.Context;\r\nimport android.content.Intent;\r\nimport android.content.IntentFilter;\r\nimport android.service.notification.NotificationListenerService;\r\nimport android.service.notification.StatusBarNotification;\r\nimport android.util.Log;\r\n\r\npublic class NLService extends NotificationListenerService {\r\n\r\n    private String TAG = this.getClass().getSimpleName();\r\n    private NLServiceReceiver nlservicereciver;\r\n    @Override\r\n    public void onCreate() {\r\n        super.onCreate();\r\n        nlservicereciver = new NLServiceReceiver();\r\n        IntentFilter filter = new IntentFilter();\r\n        filter.addAction(\"com.kpbird.nlsexample.NOTIFICATION_LISTENER_SERVICE_EXAMPLE\");\r\n        registerReceiver(nlservicereciver,filter);\r\n    }\r\n\r\n    @Override\r\n    public void onDestroy() {\r\n        super.onDestroy();\r\n        unregisterReceiver(nlservicereciver);\r\n    }\r\n\r\n    @Override\r\n    public void onNotificationPosted(StatusBarNotification sbn) {\r\n\r\n        Log.i(TAG,\"**********  onNotificationPosted\");\r\n        Log.i(TAG,\"ID :\" + sbn.getId() + \"t\" + sbn.getNotification().tickerText + \"t\" + sbn.getPackageName());\r\n        Intent i = new  Intent(\"com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE\");\r\n        i.putExtra(\"notification_event\",\"onNotificationPosted :\" + sbn.getPackageName() + \"n\");\r\n        sendBroadcast(i);\r\n\r\n    }\r\n\r\n    @Override\r\n    public void onNotificationRemoved(StatusBarNotification sbn) {\r\n        Log.i(TAG,\"********** onNOtificationRemoved\");\r\n        Log.i(TAG,\"ID :\" + sbn.getId() + \"t\" + sbn.getNotification().tickerText +\"t\" + sbn.getPackageName());\r\n        Intent i = new  Intent(\"com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE\");\r\n        i.putExtra(\"notification_event\",\"onNotificationRemoved :\" + sbn.getPackageName() + \"n\");\r\n\r\n        sendBroadcast(i);\r\n    }\r\n\r\n    class NLServiceReceiver extends BroadcastReceiver{\r\n\r\n        @Override\r\n        public void onReceive(Context context, Intent intent) {\r\n            if(intent.getStringExtra(\"command\").equals(\"clearall\")){\r\n                    NLService.this.cancelAllNotifications();\r\n            }\r\n            else if(intent.getStringExtra(\"command\").equals(\"list\")){\r\n                Intent i1 = new  Intent(\"com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE\");\r\n                i1.putExtra(\"notification_event\",\"=====================\");\r\n                sendBroadcast(i1);\r\n                int i=1;\r\n                for (StatusBarNotification sbn : NLService.this.getActiveNotifications()) {\r\n                    Intent i2 = new  Intent(\"com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE\");\r\n                    i2.putExtra(\"notification_event\",i +\" \" + sbn.getPackageName() + \"n\");\r\n                    sendBroadcast(i2);\r\n                    i++;\r\n                }\r\n                Intent i3 = new  Intent(\"com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE\");\r\n                i3.putExtra(\"notification_event\",\"===== Notification List ====\");\r\n                sendBroadcast(i3);\r\n\r\n            }\r\n\r\n        }\r\n    }\r\n\r\n}<\/pre>\n<p><strong>3. activity_main.xml<\/strong><\/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    android:paddingLeft=\"@dimen\/activity_horizontal_margin\"\r\n    android:paddingRight=\"@dimen\/activity_horizontal_margin\"\r\n    android:paddingTop=\"@dimen\/activity_vertical_margin\"\r\n    android:paddingBottom=\"@dimen\/activity_vertical_margin\"\r\n    tools:context=\".MainActivity\"&gt;\r\n\r\n    &lt;Button\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:text=\"Create Notification\"\r\n            android:id=\"@+id\/btnCreateNotify\"\r\n            android:onClick=\"buttonClicked\"\r\n            android:layout_alignParentTop=\"true\"\r\n            android:layout_alignParentLeft=\"true\"\r\n            android:layout_alignParentRight=\"true\"\/&gt;\r\n\r\n    &lt;Button\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:text=\"Clear All Notification\"\r\n            android:id=\"@+id\/btnClearNotify\"\r\n            android:onClick=\"buttonClicked\"\r\n            android:layout_below=\"@+id\/btnCreateNotify\"\r\n            android:layout_alignLeft=\"@+id\/btnCreateNotify\"\r\n            android:layout_alignRight=\"@+id\/btnCreateNotify\"\/&gt;\r\n\r\n    &lt;ScrollView android:layout_width=\"match_parent\"\r\n                android:layout_height=\"match_parent\"\r\n                android:layout_alignParentBottom=\"true\"\r\n                android:layout_alignRight=\"@+id\/btnListNotify\"\r\n                android:layout_below=\"@+id\/btnListNotify\"\r\n                android:layout_alignLeft=\"@+id\/btnListNotify\"&gt;\r\n\r\n        &lt;TextView\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:textAppearance=\"?android:attr\/textAppearanceMedium\"\r\n                android:text=\"NotificationListenerService Example\"\r\n                android:id=\"@+id\/textView\"\r\n                \/&gt;\r\n\r\n    &lt;\/ScrollView&gt;\r\n\r\n    &lt;Button\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:text=\"List of Notification\"\r\n            android:id=\"@+id\/btnListNotify\"\r\n            android:onClick=\"buttonClicked\"\r\n            android:layout_below=\"@+id\/btnClearNotify\"\r\n            android:layout_alignLeft=\"@+id\/btnClearNotify\"\r\n            android:layout_alignRight=\"@+id\/btnClearNotify\"\/&gt;\r\n&lt;\/RelativeLayout&gt;<\/pre>\n<p><strong>4. AndroidManifest.xml<\/strong><\/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.kpbird.nlsexample\"\r\n    android:versionCode=\"1\"\r\n    android:versionName=\"1.0\" &gt;\r\n\r\n    &lt;uses-sdk\r\n        android:minSdkVersion=\"18\"\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        &lt;activity\r\n            android:name=\"com.kpbird.nlsexample.MainActivity\"\r\n            android:label=\"@string\/app_name\"\r\n            android:screenOrientation=\"portrait\"&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;service android:name=\"com.kpbird.nlsexample.NLService\"\r\n                 android:label=\"@string\/app_name\"\r\n                 android:permission=\"android.permission.BIND_NOTIFICATION_LISTENER_SERVICE\"&gt;\r\n            &lt;intent-filter&gt;\r\n                &lt;action android:name=\"android.service.notification.NotificationListenerService\" \/&gt;\r\n            &lt;\/intent-filter&gt;\r\n        &lt;\/service&gt;\r\n    &lt;\/application&gt;\r\n\r\n&lt;\/manifest&gt;<\/pre>\n<h2>User following code to open Notification Access setting screen<\/h2>\n<pre class=\" brush:java\">Intent intent=new Intent(\"android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS\");\r\nstartActivity(intent);<\/pre>\n<ul>\n<li><a href=\"https:\/\/github.com\/kpbird\/NotificationListenerService-Example\">Download Source Code from GitHub<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><i>Reference: <\/i><\/b><a href=\"http:\/\/www.kpbird.com\/2013\/07\/android-notificationlistenerservice.html\">Android NotificationListenerService Example<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Ketan Parmar at the <a href=\"http:\/\/www.kpbird.com\/\">KP Bird<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction NotificationListenerService is introduced in Android 4.3 (API 18). It allows an application to receive information about notifications as it creates or removes. NotificationListenerService class is derived from the Service class. It has two abstract methods namely 1. onNotificationPosted 2. onNotificationRemoved. To use NotificationListenerService, we need to create a java file which extends NotificationListenerService and &hellip;<\/p>\n","protected":false},"author":498,"featured_media":46,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-18095","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>Android NotificationListenerService Example<\/title>\n<meta name=\"description\" content=\"Introduction NotificationListenerService is introduced in Android 4.3 (API 18). It allows an application to receive information about notifications as it\" \/>\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\/10\/android-notificationlistenerservice-example.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android NotificationListenerService Example\" \/>\n<meta property=\"og:description\" content=\"Introduction NotificationListenerService is introduced in Android 4.3 (API 18). It allows an application to receive information about notifications as it\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-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-10-15T16:00:44+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=\"Ketan Parmar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/kpbird\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ketan Parmar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/android-notificationlistenerservice-example.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/android-notificationlistenerservice-example.html\"},\"author\":{\"name\":\"Ketan Parmar\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/60fbe6f84ddb60deb9f25ae7cd53fb09\"},\"headline\":\"Android NotificationListenerService Example\",\"datePublished\":\"2013-10-15T16:00:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/android-notificationlistenerservice-example.html\"},\"wordCount\":286,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/android-notificationlistenerservice-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\\\/10\\\/android-notificationlistenerservice-example.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/android-notificationlistenerservice-example.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/android-notificationlistenerservice-example.html\",\"name\":\"Android NotificationListenerService Example\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/android-notificationlistenerservice-example.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/android-notificationlistenerservice-example.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"datePublished\":\"2013-10-15T16:00:44+00:00\",\"description\":\"Introduction NotificationListenerService is introduced in Android 4.3 (API 18). It allows an application to receive information about notifications as it\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/android-notificationlistenerservice-example.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/android-notificationlistenerservice-example.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/android-notificationlistenerservice-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\\\/10\\\/android-notificationlistenerservice-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\":\"Android NotificationListenerService 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\\\/60fbe6f84ddb60deb9f25ae7cd53fb09\",\"name\":\"Ketan Parmar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ea97dd7abd89ea61efff22add8e2dcd323304653dd6b8e2bfbe2aa907d0470aa?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ea97dd7abd89ea61efff22add8e2dcd323304653dd6b8e2bfbe2aa907d0470aa?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ea97dd7abd89ea61efff22add8e2dcd323304653dd6b8e2bfbe2aa907d0470aa?s=96&d=mm&r=g\",\"caption\":\"Ketan Parmar\"},\"description\":\"Ketan Parmar (aka KPBird) is software engineer with 7 years experience, He is passionate about Java (SE,EE,ME),Android,BlackBerry, Grid Computing, Big Data, UI\\\/UX and Open Source\",\"sameAs\":[\"http:\\\/\\\/kpbird.com\",\"http:\\\/\\\/www.linkedin.com\\\/in\\\/kpbird\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/kpbird\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/ketan-parmar\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android NotificationListenerService Example","description":"Introduction NotificationListenerService is introduced in Android 4.3 (API 18). It allows an application to receive information about notifications as it","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\/10\/android-notificationlistenerservice-example.html","og_locale":"en_US","og_type":"article","og_title":"Android NotificationListenerService Example","og_description":"Introduction NotificationListenerService is introduced in Android 4.3 (API 18). It allows an application to receive information about notifications as it","og_url":"https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-example.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-10-15T16:00:44+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":"Ketan Parmar","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/kpbird","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Ketan Parmar","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-example.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-example.html"},"author":{"name":"Ketan Parmar","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/60fbe6f84ddb60deb9f25ae7cd53fb09"},"headline":"Android NotificationListenerService Example","datePublished":"2013-10-15T16:00:44+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-example.html"},"wordCount":286,"commentCount":7,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-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\/10\/android-notificationlistenerservice-example.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-example.html","url":"https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-example.html","name":"Android NotificationListenerService Example","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-example.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-example.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","datePublished":"2013-10-15T16:00:44+00:00","description":"Introduction NotificationListenerService is introduced in Android 4.3 (API 18). It allows an application to receive information about notifications as it","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-example.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-example.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/android-notificationlistenerservice-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\/10\/android-notificationlistenerservice-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":"Android NotificationListenerService 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\/60fbe6f84ddb60deb9f25ae7cd53fb09","name":"Ketan Parmar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ea97dd7abd89ea61efff22add8e2dcd323304653dd6b8e2bfbe2aa907d0470aa?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ea97dd7abd89ea61efff22add8e2dcd323304653dd6b8e2bfbe2aa907d0470aa?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ea97dd7abd89ea61efff22add8e2dcd323304653dd6b8e2bfbe2aa907d0470aa?s=96&d=mm&r=g","caption":"Ketan Parmar"},"description":"Ketan Parmar (aka KPBird) is software engineer with 7 years experience, He is passionate about Java (SE,EE,ME),Android,BlackBerry, Grid Computing, Big Data, UI\/UX and Open Source","sameAs":["http:\/\/kpbird.com","http:\/\/www.linkedin.com\/in\/kpbird","https:\/\/x.com\/https:\/\/twitter.com\/kpbird"],"url":"https:\/\/www.javacodegeeks.com\/author\/ketan-parmar"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/18095","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\/498"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=18095"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/18095\/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=18095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=18095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=18095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}