Android 卸载应用程序接收器
我使用下面的代码来获得卸载包广播接收器,但我没有得到任何响应。有人能说出代码有什么问题吗Android 卸载应用程序接收器,android,Android,我使用下面的代码来获得卸载包广播接收器,但我没有得到任何响应。有人能说出代码有什么问题吗 AndroidManifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="pack.test" android:versionCode="1" android:versionName="1.0" > <uses-sdk android
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pack.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".TestprojectActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="UninstallApk">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
</intent-filter>
</receiver>
</application>
</manifest>
UninstallApk.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class UninstallApk extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.i("DATA", "Apk uninstall");
Toast.makeText(context,"APK uninstall",Toast.LENGTH_LONG).show();
}
}
AndroidManifest.xml
卸载apk.java
导入android.content.BroadcastReceiver;
导入android.content.Context;
导入android.content.Intent;
导入android.util.Log;
导入android.widget.Toast;
公共类卸载APK扩展了BroadcastReceiver{
@凌驾
公共void onReceive(上下文、意图){
Log.i(“数据”、“Apk卸载”);
Toast.makeText(上下文,“APK卸载”,Toast.LENGTH_LONG.show();
}
}
当我插入充电器时,它会显示Toast,但当我卸载任何其他应用程序表单application->manage application时,它不会显示任何响应
谢谢。请先搜索SO上的问题,你可能会得到你想要的答案,因为有人问过这个问题
在您的情况下,必须为
广播接收器
设置数据模式。我已经回答了这样一个问题(它也适用于PACKAGE\u REMOVED
操作)。查看此链接。请先搜索SO上的问题,您可能会得到您想要的答案,因为其他人已经问过了
在您的情况下,必须为
广播接收器
设置数据模式。我已经回答了这样一个问题(它也适用于PACKAGE\u REMOVED
操作)。查看此链接。您需要将android.permission.BROADCAST\u PACKAGE\u REMOVED
添加到AndroidManifest.xml
您需要将android.permission.BROADCAST\u PACKAGE\u REMOVED
添加到AndroidManifest.xml
发送此事件时,需要此权限的可能重复项,不接收。发送此事件而不是接收此事件需要此权限。