我想在安装新应用程序时收到通知。
IntentFilter newAppFilter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
newAppFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
newAppFilter.addAction(Intent.ACTION_PACKAGE_INSTALL);
newAppFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
getApplicationContext().registerReceiver(newAppReceiver, newAppFilter);
public static BroadcastReceiver newAppReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
Log.e("Broadcast","Received");
}
};
但是我无法获取任何日志。谁能帮帮我?
最佳答案
尝试将数据方案添加到您的 IntentFilter
。
newAppFilter.addDataScheme("package");
引用:IntentFilter.addDataScheme()文档
If no schemes are included, then an Intent will match only if it includes no data.
关于android - 新应用安装的 BroadcastReceiver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6213596/