如何获得通知时,通知被通知

编程入门 行业动态 更新时间:2024-10-11 23:22:34
本文介绍了如何获得通知时,通知被通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想读/门禁/登录其他应用程序解雇的通知栏上的通知。

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.!!! :)

更多推荐

如何获得通知时,通知被通知

本文发布于:2023-11-27 14:59:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638540.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通知   如何获得

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!