0

I want to hide any application(whatsapp, facebook...) from my app. I try with my own app hide/unhide from list. Its work perfectly. But I want to hide another app from my app. I try with this code.

I getting app package name & its activity name using this code.

public void getPackageAndActivityname() {
    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));

    for (ResolveInfo temp: appList) {
        Log.e("HIDEAPP", "package:- " + temp.activityInfo.packageName + "    activity name:- " + temp.activityInfo.name);
    }
}

Use this package name & activity name in below method(eg. hide UC Brower).

public void hideApp() {
    PackageManager p = getPackageManager();
    ComponentName componentName = new ComponentName("com.UCMobile.intl", "com.uc.browser.UCMobileApp");  // ucWebbrowser hide from app list
    p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}

And my manifest file put this permission.

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>

But i am getting this type of error

java.lang.SecurityException: Permission Denial: attempt to change component state from pid=26587, uid=10477, package uid=10426

I refer this two links. Link 1 And Link 2. But I am getting this type of error.I run this app in Motorola Moto G phone(OS: Kitkat 4.4.4). How can I solve this problem?

Community
  • 1
  • 1
Jigar Shekh
  • 2,800
  • 6
  • 29
  • 54

1 Answers1

2

How can I solve this problem?

You can hide your application icon only once after it launch first time.

No You can not hide the icon of other apps. You don't have a control to update these settings of other apps.

Each android apps run in different process and system assign a different id to each apps so you dont have a access to update the settings of one process from another. This can be possible if your device is rooted.

N Sharma
  • 33,489
  • 95
  • 256
  • 444