Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';在android中清除包时,无法调用onReceive()_Android - Fatal编程技术网

Can';在android中清除包时,无法调用onReceive()

Can';在android中清除包时,无法调用onReceive(),android,Android,我正在使用此代码为包注册广播接收器 <receiver android:name="com.abc.abc.activity.Receiver" android:exported="true" > <intent-filter> <action android:name="android.intent.action.PACKAGE_ADDED" /> <action android:name="and

我正在使用此代码为包注册广播接收器

<receiver
  android:name="com.abc.abc.activity.Receiver"
  android:exported="true" >
     <intent-filter>
         <action android:name="android.intent.action.PACKAGE_ADDED" />
         <action android:name="android.intent.action.PACKAGE_REMOVED" />
         <action android:name="android.intent.action.PACKAGE_DATA_CLEARED" />
         <category android:name="android.intent.category.DEFAULT" />
         <data android:scheme="package" />
        </intent-filter></receiver>

但当我清除应用程序的数据时,不会调用它

有人能帮我吗
提前谢谢

我现在对它进行了测试,并使用以下代码对我有效:

<receiver android:name=".permission_policy.AppInstallRemoveReceiver">
             <intent-filter android:priority="100">
                  <action 
android:name="android.intent.action.PACKAGE_INSTALL"/>
                  <action 
android:name="android.intent.action.PACKAGE_ADDED"/>
                  <action 
android:name="android.intent.action.PACKAGE_DATA_CLEARED"/>
                  <action 
android:name="android.intent.action.PACKAGE_REMOVED"/>
                  <data android:scheme="package"/>
             </intent-filter>
         </receiver>

来自Android.intent.action.PACKAGE\u DATA\u上的Android SDK

请注意,清除的程序包不接收此广播


因此,您自己的数据已被清除,您似乎不会收到通知。

您好,谢谢您的回答,但我在清除手机中安装的另一个应用程序的数据时,我会呼叫它,但我想在清除自己应用程序的数据时呼叫它。在这种情况下,我能想到的唯一解决方案是建立一个新的应用程序app-B,当清理应用程序a时,它将被调用。我在这里面临同样的问题。但是,创建一个新的应用程序来观看上一个应用程序并不是一个好主意。