android - See notification of other app -


what api should use app see if i've received notification example facebook, , write in 1 textbox "facebook!"?

your best bet use notificationlistenerservice, added in api level 18.

here's example:

public class facebooknotificationlistener extends notificationlistenerservice {      @override     public void onnotificationposted(statusbarnotification sbn) {         final string packagename = sbn.getpackagename();         if (!textutils.isempty(packagename) && packagename.equals("com.facebook.katana")) {             //         }     }      @override     public void onnotificationremoved(statusbarnotification sbn) {         // nothing     }  } 

in androidmanifest

<service     android:name="your.path.to.facebooknotificationlistener"     android:permission="android.permission.bind_notification_listener_service" >     <intent-filter>         <action android:name="android.service.notification.notificationlistenerservice" />     </intent-filter> </service> 

also, users need enable app listen notifications posted under:

  • settings --> security --> notification access

but can direct users straight there using following intent:

startactivity(new intent("android.settings.action_notification_listener_settings")); 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -