1

I want to hide any application (Telegram, Viber, ...) from my app Android. 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 by Praful Bhatnagar:

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?

Ryan M
  • 18,333
  • 31
  • 67
  • 74
Homa Shafiei
  • 41
  • 12

1 Answers1

0

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.

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.

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491