本文介绍了如何获得通知时,通知被通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想读/门禁/登录其他应用程序解雇的通知栏上的通知。
I want to read/access/log the notifications fired on notification bar by other applications.
我搜索意图和 PendingIntents 很多,但不能得到解决。
I searched Intents and PendingIntents a lot, but couldn't get a solution.
请问我的应用程序需要被通知当任何通知解雇了?
Does my application need to be notified when any notification is fired?
还是Android系统提供一些用户级应用程序来读取通知?
Or Does android system provide something to read notifications by the user-level applications?
推荐答案终于得到了答案。!使用 AccessibilityService
Finally got the answer.!!! Using AccessibilityService
public class NotificationService extends AccessibilityService { @Override public void onAccessibilityEvent(AccessibilityEvent event) { // TODO Auto-generated method stub. //Code when the event is caught } @Override public void onInterrupt() { // TODO Auto-generated method stub. } @Override protected void onServiceConnected() { AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.feedbackType = 1; info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; info.notificationTimeout = 100; setServiceInfo(info); } }和我的清单是:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="schemas.android/apk/res/android" package="org.test.notify" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <service android:name=".NotificationService" android:enabled="true"> <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <action android:name="android.accessibilityservice.AccessibilityService"/> </intent-filter> </service> </application> </manifest>
享受编码。! :)
Enjoy Coding.!!! :)
更多推荐
如何获得通知时,通知被通知
发布评论