我想在删除包时捕获事件。我使用以下内容: BroadcastReceiver 子类:
public class CustomBroadcastReceiver extends BroadcastReceiver {
/**
* This method captures the event when a package has been removed
*/
@Override
public void onReceive(Context context, Intent intent)
{
Helper.writeInLogFile("Hello from CustomBroadcastReceiver");
if (intent != null) {
String action = intent.getAction();
if (action.equals(intent.ACTION_PACKAGE_REMOVED)) {
//Log the event capture in the log file ...
Helper.writeInLogFile("The package has been removed");
}
}
}
}
及其清单部分:
<receiver android:name="CustomBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REMOVED" >
</action>
</intent-filter>
</receiver>
...但 CustomBroadcastReceiver 没有被解雇。我究竟做错了什么?谢谢