How to hide inside app icon on android marshmallow? - android

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);

Related

Error hiding app icon after asking permitions in Android Manifest xml

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.

Android: How to unhide app

I want to allow the users of my Android app to hide/unhide it when they want.
I already have the code to perform the hide/unhide actions, and the hiding works fine.
But now how can I call the unhide method to let the app back?
I mean, if the app is hidden, where can the user, let's say, "click a button" that calls the method to make the app unhide?
Here is my hide/unhide code:
// method to hide the app icon
public static void hideAppIcon(final Context context)
{
PackageManager p = context.getPackageManager();
// activity which is first time open in manifest file which is declare as <category android:name="android.intent.category.LAUNCHER" />
ComponentName componentName = new ComponentName(context, SplashActivity.class);
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
// method to unhide the app icon
public static void unhideAppIcon(final Context context)
{
PackageManager p = context.getPackageManager();
// activity which is first time open in manifest file which is declare as <category android:name="android.intent.category.LAUNCHER" />
ComponentName componentName = new ComponentName(context, SplashActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
}
Here's a way I've learned from another app. Not "hiding" the icon, instead, change the icon and label of your app. Disguise the app as some built-in apps like "Settings" or "Calculator".
Another solution (which might be closer to your need) is to add an intent-filter in your app, detecting something like phone calls. If users call a certain number, you unhide your app.
see this for more infomation.
Hope this will help.

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

hide application icon in menu of android phone

I am new at android. I want to hide my application icon from main menu at the run time. I believe that a manifest file is responsible for the application's presence in the main menu. But I want my application in running process while switching on android phone. But it doesn't show the application icon in menu at phone.
Will you please tell me a solution for the same.
If you don't want your application appear among the launchable applications with an icon just edit your AndroidManifest.xml
and remove the following:
<category android:name="android.intent.category.LAUNCHER" />
The following line will tell android to show the app in the launcher.
Here is the Working code Snippt :
ComponentName componentToDisable = new ComponentName(
getApplicationContext().getPackageName(), Constant.main_package_name
+ ".Splash"); // .Splash Launcher Activity
getPackageManager().setComponentEnabledSetting(
componentToDisable,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
finishActivities(); // Finish All activity

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