Error hiding app icon after asking permitions in Android Manifest xml - android

I made an app to automatically hide its icon after launched.
I used this code to make this system
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, MainActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
Everything works fine until I try to request permissions in my Android Manifest XML,
for example
<uses-permission android:name="android.permission.SEND_SMS" />
on asking the permission the app ignores the script and it doesn't hide the icon
Note: the only error is that my app doesn't hide, the rest of the app works perfectly.

Related

How to hide inside app icon on android marshmallow?

I use marshmallow android.
I want inside app. Camera,Setting,internet... hide icon.
I know how to hide icon on kitkat android.
but I don't know how to hide icon on marshmallow.
how to hide app icon on android marshmallow?
use below code along with Package manager permission
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class); // activity which is first time open in manifiest file which is declare as <category android:name="android.intent.category.LAUNCHER" />
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

How to hide all the app icons installed in android except setting and my installed app icon

I'm trying to make an app which would have this function that when i install this app only on tablet device then all the apps icon installed before my app on that tablet got hide. the main screen should look like that only my app icon and setting icon is shown on screen.
I used the following code but it only hiding my app icon not others. Can I do this or not ? if I can then help me for this. here is the code
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName
(this, com.example.junaidsaif.skyhighreward.MainScreen.class); // activity which is first time open in manifiest file which is declare as <category android:name="android.intent.category.LAUNCHER" />
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
please help me for this

Issue in Hiding a application from another Application in Android

What i am trying to do is hiding a installed application from another application like this :
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName("com.example.activitypackgename","com.example.activitypackgename.LauncherActivity");
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
but it is throwing exception
java.lang.SecurityException: Permission Denial: attempt to change
component state
code works fine if trying to hide same application. I need to know is their any way to hide a app from another app.? Thanks in advance.

android hide app icon and make it visible

I'm working on my app. there's two app, one should be hide. and open by another one. I try code like this in app A
PackageManager p = getPackageManager();
p.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
and try to open app A by code
Intent intent = MainActivity.this.getPackageManager()
.getLaunchIntentForPackage("com.example.hideicon");
startActivity(intent);
but it didn't work.
For hide app icon
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(Test.this,com.example.MainActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
For display app icon
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(Test.this, com.example.MainActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
It will not work since you have disabled the component and haven't enabled it before starting. To disable/enable it requires the permission.
please check this link i hope its useful to you.
reference link
remove launcher in manifest file from main acitivity.and programatically set it.
I solve my question . firstly you must hide your app icon by remove
<category android:name="android.intent.category.LAUNCHER"
second you can add code in app B
Intent intent = new Intent("com.example.hideicon");
intent.setComponent(ComponentName
.unflattenFromString("com.example.hideicon/com.example.hideicon.MainActivity"));
intent.addCategory("android.intent.category.LAUNCHER");
startActivity(intent);

Android how to programmatically hide launcher icon

my app is designed to only need to be run once. As such I want to hide the icon from the launcher after the first run, but without uninstalling the app.
I have seen similar applications - they can remove their own icons from the launcher app list. How can I achieve the same results? Thank you.
PackageManager p = getPackageManager();
p.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
Note that the icon may not be gone until the next reboot.
Hide app's icon using below code
PackageManager pkg=this.getPackageManager();
pkg.setComponentEnabledSetting(new ComponentName(this,SplashActivity.class),PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
// activity which is first time open in manifiest file which is declare as <category android:name="android.intent.category.LAUNCHER" />
Here is how to bring back the app's icon
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this,SplashActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
With Android Q (API 29) Google changed the Launcher icon visibility behaviour. Even if you disable your Launcher Activity or completely remove the
android.intent.category.LAUNCHER <intent-filter> from all your Activities, the app will appear in the launcher and open the Android OS app settings, with the exception of:
Packages that don't declare any permissions in their respective manifest files
System apps
Apps that don't contain any components inside their
respective manifest's tag
You can have an app without a launcher by NOT including an intent filter with MAIN and LAUNCHER in the declaration of the Activity in the AndroidManifest - the question then becomes how to do the first kick off.. Widget maybe ?
Hide app icon using this code:
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class); // activity which is first time open in manifiest file which is declare as <category android:name="android.intent.category.LAUNCHER" />
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
and bring it back, with this:
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
NOTE: This will not work for Android 10

Categories

Resources