我在我的 android 应用程序中使用 BroadcastReceiver,我在 JB 4.1 上运行我的应用程序
在清单中我已注册为
<receiver android:name=".ThemeInstalledBroadcastReceiver" android:enabled="true">
<intent-filter android:priority="100">
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
当我安装任何应用程序 ThemeInstalledBroadcastReceiver 类被触发但是当我安装一些主题时 ThemeInstalledBroadcastReceiver 不会被触发。但是当我在 JB 4.2 上运行此应用程序时,它运行良好
我的接收方代码是这样的
public class ThemeInstalledBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent arg1) {
System.out.println("Mass_TC inside InstalledBroadcastReceiver res " + arg1.getAction().equals(Intent.ACTION_PACKAGE_ADDED) );
System.out.println("Mass_TC apkid " + arg1.getData().getEncodedSchemeSpecificPart() + " intent : " + arg1);
}
}
安装应用程序时的日志
I/System.out(19647): Mass_TC apkid com.example.ttest intent : Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.ttest flg=0x8000010 cmp=com.myrrom.themechooser/.InstalledBroadcastReceiver (has extras) }
I/System.out(19647): Mass_TC deleting apkid : com.example.ttest x : 0
I/System.out(19647): Mass_TC inside InstalledBroadcastReceiver res true
I/System.out(19647): Mass_TC apkid com.example.test_fa intent : Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.test_fa flg=0x8000010 cmp=com.myrrom.themechooser/.InstalledBroadcastReceiver (has extras) }
I/System.out(19647): Mass_TC deleting apkid : com.example.test_fa x : 0
但是当我安装任何主题时,我没有得到任何日志