安卓通知应用

编程入门 行业动态 更新时间:2024-10-19 18:15:59
本文介绍了安卓通知应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我目前正在开发一个 android 应用程序.每当用户安装/下载新的第三方应用程序时,我都必须记录任何新安装的应用程序名称.如果用户正在安装新应用程序,我如何获得通知.提前致谢.

I'm currently working on an android application. I have to log any new installed app name whenever the user is installing/downloading a new third party app. How can I get the notification if the user is installing a new app. Thanks in advance.

public class ApplicationBroadcastService extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { System.out.print("-------"); } }

清单

<receiver android:name=".applicationlog.ApplicationBroadcastService"> <intent-filter> <action android:name="android.intent.action.PACKAGE_ADDED" /> <action android:name="android.intent.action.PACKAGE_CHANGED" /> <action android:name="android.intent.action.PACKAGE_INSTALL" /> <action android:name="android.intent.action.PACKAGE_REMOVED" /> <action android:name="android.intent.action.PACKAGE_REPLACED" /> </intent-filter> </receiver>

但是当我安装/卸载任何应用程序时,我仍然没有进入 onReceive 方法.

But still I do not enter the onReceive method, when I am installing/uninstalling any app.

解决办法如下:

我对 Manifest 文件做了一个小改动.

I did a small change in my Manifest file.

<intent-filter> <category android:name="android.intent.category.DEFAULT" /> <action android:name="android.intent.action.PACKAGE_ADDED" /> <action android:name="android.intent.action.PACKAGE_CHANGED" /> <action android:name="android.intent.action.PACKAGE_INSTALL" /> <action android:name="android.intent.action.PACKAGE_REMOVED" /> <action android:name="android.intent.action.PACKAGE_REPLACED" /> <data android:scheme="package" /> </intent-filter>

现在一切正常.. :)再次感谢@willytate

Now it's working fine.. :) Thanks again @willytate

推荐答案

Ajay,

您需要使用 Intent 过滤器设置 BroadcastReceiver 以接收以下操作:ACTION_PACKAGE_ADDED 然后从 BroadcastReceiver 的 onReceive() 方法你可以启动一个 Notification.

You will need to setup a BroadcastReceiver with an intent filter to receive the following Action: ACTION_PACKAGE_ADDED then from the onReceive() method of the BroadcastReceiver you can launch a Notification.

更多推荐

安卓通知应用

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

发布评论

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

>www.elefans.com

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