我想获取接收到的intent
的包名和类名,但我无法获取。
我想让我的应用程序安全,所以它在卸载前要求输入密码。只有安装应用程序的用户知道密码,因此只有他/她才能卸载应用程序。
我的接收器代码:
public class PackageReceiver extends BroadcastReceiver {
@ Override
public void onReceive (Context context, Intent intent) {
if (intent.getAction().equals("android.settings.APPLICATION_DETAILS_SETTINGS")) {
/ / TODO:
//I want here to get this getAction working and then I want to fetch package and class of the intent
}
}
}
list :
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RESTART_PACKAGES"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<Application
android: icon = "@ drawable / ic_launcher"
android: label = "Test">
<Receiver android: name = ". PackageReceiver"
android: label = "@ string / app_name">
<intent-filter>
<action android:name="android.settings.APPLICATION_DETAILS_SETTINGS" />
<data android:scheme="package" />
</ Intent-filter>
</ Receiver>
</ Application>
如果我缺少任何许可,请告诉我,因为我无法使它正常工作。
最佳答案
我个人认为这种行为很烦人。并且肯定它是多余的:已经有其他机制可以解决相同的问题(屏幕锁定,加密)。
我只会在操作在您这边时使用额外的检查(即:删除帐户、更改电子邮件等)。
如果我没有阻止你这样做的话 here's另一个帖子按照类似的方向解决了同样的问题。
关于android - 为我的应用程序接收 Intent "android.settings.APPLICATION_DETAILS_SETTINGS",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18427193/