Android編碼過程易出錯記錄(不斷更新中...)

1.當廣播類註冊的action包含addDataScheme時,好比PACKAGE_ADDED、PACKAGE_REMOVED,若是再註冊其餘不須要addDataScheme,好比SCREEN_ON、SCREEN_OFF或者自定義廣播,會形成接收不到這些不須要addDataScheme的廣播

installAppReceiver = new InstallAppReceiver();
IntentFilter filter2 = new IntentFilter();
filter2.addAction(Intent.ACTION_SCREEN_OFF);
filter2.addAction(Intent.ACTION_PACKAGE_ADDED);
filter2.addDataScheme("package");
context.registerReceiver(installAppReceiver, filter2);

好比上面這種就收不到SCREEN_OFF廣播。java

相關文章
相關標籤/搜索