- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
你好,我正在尝试检测已安装的应用程序,以便我可以对应用程序进行一些分析,我正在使用我在 stackoverflow 上找到的这个示例来监听来 self 当前应用程序的包安装,但我的 logcat 中没有发生任何事情。
void registerReceiver() {
IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addDataScheme("package");
}
public void onReceive(Context context, Intent intent) {
String actionStr = intent.getAction();
if (Intent.ACTION_PACKAGE_ADDED.equals(actionStr)) {
Uri data = intent.getData();
String pkgName = data.getEncodedSchemeSpecificPart();
//handle package adding...
Log.i("Logging Service", pkgName);
}
}
<receiver android:name="RealTimeActivity">
<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" />
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_ADDED" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_CHANGED" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_INSTALL" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_REPLACED" />
最佳答案
由于自 Android 3.1 起广播行为发生了变化,您的应用必须先启动才能接收应用安装/删除 Intent 。看歌舞伎的回答in this thread .
以下接收器在 Android 4.0 设备上为我工作(我在应用程序中有一个 Activity ,首先启动 Activity 即应用程序也启动,然后接收器可以接收广播)。
<receiver android:name=".MyReceiver">
<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_REMOVED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
(一些应用程序运行虚拟粘性服务来保持应用程序进程处于 Activity 状态,以便它们可以接收某些广播)
关于android - Intent PACKAGE_ADDED 未注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12834594/
我在 list 中注册了一个广播接收器: 接收者: public class NewAppReceiver ext
你好,我正在尝试检测已安装的应用程序,以便我可以对应用程序进行一些分析,我正在使用我在 stackoverflow 上找到的这个示例来监听来 self 当前应用程序的包安装,但我的 logcat 中没
我的 BroadcastReceiver 对象需要监听 PACKAGE_REMOVED/PACKAGE_ADDED Intent 。完成此操作需要什么权限? 最佳答案 您不需要任何权限。看看这里: h
我正在实现 HeyZap,它需要我添加 AndroidManifest.xml 中的这些行是否需要用户许可才能更新或自动更新我的 Google Play 用户?通常用户权限不是
我在下面给出的代码中遇到了这个异常。我不知道这段代码有什么问题。请帮我摆脱这个异常。 05-23 23:33:49.853: E/BroadcastReceiver(26895): Broadcast
我必须接收系统发送的隐式广播 (ACTION_PACKAGE_ADDED) 以检测应用程序的安装并执行一些代码。我使用了下面的代码: public class Receiver extends Bro
我正在创建一个应用程序,它将向我发送各种操作的事件,我在单个类中添加了波纹管事件,效果很好。
我要做的只是在每次安装和卸载时更新我的列表,但不是在 Package Replace 上。所以主要问题是在每次 Replace 操作时都会启动安装和卸载 Intent 。 p> 所以为此,我实现了
我正在创建实现 LocationListener、GooglePlayServicesClient 的 MainActivity 类,以使用 FusedLocationApi 获取当前位置。它向我显示
我在我的 android 应用程序中使用 BroadcastReceiver,我在 JB 4.1 上运行我的应用程序 在 list 中我已经注册为
我是一名优秀的程序员,十分优秀!