[英]How to Hide other apps from my app?
I want to hide any application (Telegram, Viber, ...) from my app Android. 我想从我的应用程序Android隐藏任何应用程序(电报,Viber等)。 I want to hide another apps in list installed apps from my app.
我想从我的应用中隐藏已安装列表中的其他应用。 I try with this code.
我尝试使用此代码。 I getting app package name and its activity name using this code:
我使用以下代码获取应用程序包名称及其活动名称:
private void hideapplication() {
final PackageManager pm = getPackageManager();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> appList = pm.queryIntentActivities(mainIntent, 0);
Collections.sort(appList, new ResolveInfo.DisplayNameComparator(pm));
TextView textview= (TextView)findViewById(R.id.textview);
ImageView imageview =(ImageView)findViewById(R.id.imageview);
for (ResolveInfo temp: appList) {
Log.v("my logs", "package and activity name = " + temp.activityInfo.packageName + " " + temp.activityInfo.name);
}
} }
Use this package name & activity name in below code: 在以下代码中使用此程序包名称和活动名称:
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.isChecked()) {
Toast.makeText(context, "Checked", Toast.LENGTH_SHORT).show();
ComponentName componentName = new ComponentName(applicationInfo.packageName, applicationInfo.name);
packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
}
}); });
But I am getting force close. 但是我越来越近了。 How can I solve this problem?
我怎么解决这个问题? Can you help me?
你能帮助我吗?
I want to hide another apps in list installed apps from my app
我想从我的应用中隐藏已安装列表中的其他应用
Fortunately, this is not possible, except via a custom ROM or probably a rooted device. 幸运的是,这是不可能的,除非通过自定义ROM或可能是有根设备。
You can do something similar to this via Android at Work, but your app would need to be a device owner, which requires that your app be set up as part of first powering on the device. 您可以通过Android at Work来执行类似的操作,但是您的应用必须是设备所有者,这要求您在首次启动设备时设置您的应用。
Use this package name & activity name in below code:
在以下代码中使用此程序包名称和活动名称:
Your app does not have the rights to change the enabled status of components of other apps. 您的应用无权更改其他应用的组件的启用状态。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.