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
Related
Is it possible to create an app without any activities? Without a launcher icon and without the "open" button on Play Store? Like this one https://my.pcloud.com/publink/show?code=XZUi3I7Z6yNkHyuBISL5XynlYYI8SjEJcoMk
I only need it to create a background service.
I've done some research and I haven't found anything about this. If you could just point me in a direction (or tell me it's not possible) it would be great!
Cheers!
You said you didn't want to use a translucent Activity, but that seems to be the best way to do this:
1- In your Manifest, set the Activity theme to Theme.Translucent.NoTitleBar.
2- Don't bother with a layout for your Activity, and don't call setContentView().
3- In your Activity's onCreate(), start your Service with startService().
4- Exit the Activity with finish() once you've started the Service.
In other words, your Activity doesn't have to be visible; it can simply make sure your Service is running and then exit, which sounds like what you want.
how to hide luncher icon :
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);
Hide open button couldn't be done , because we are talking about an application and not a google library
how to unhide icon :
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
IMPORTANT: It's somehow tricky if you need to do something with main activity in your app when it's hidden. you will face an ActivityNotFoundException. to make it work, you should unhide icon before doing anything to your main activity and hide it again after you are finished.
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);
I hope anyone can help me or give me a clear solution,
I have an app that I don't want to be opened directly from the user, so I need to hide its icon.
and in the other hand, I want to access this application from another app (App2), so I wrote this code in the function of onClick of a certain button of App2:
Intent launchIntent = getPackageManager().getLaunchIntentForPackage(package name of the first app );
startActivity(launchIntent);
Before hiding the App1 , everything was working perfectly No errors but after hiding it using the following code, it crashes:
PackageManager packageManager = this.getPackageManager();
ComponentName componentName = new ComponentName(this,FingerActivity.class);
packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
and the following error appear in Android Studio:
Starting: Intent { act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER]
cmp=com.neurotec.samples.multibiometric/.fingers.FingerActivity }
Error type 3 Error: Activity class
{com.neurotec.samples.multibiometric/com.neurotec.samples.multibiometric.fingers.FingerActivity}
does not exist.
any idea?
any idea?
You disabled the component. You cannot start the component from any other app.
I have an app that I don't want to be opened directly from the user, so I need to hide its icon.
The simplest way for it to not have an icon is for you to not give it an icon. Change your <intent-filter> for that activity to be something custom for you, rather than having it have the MAIN/LAUNCHER values that causes home screens to put an icon for it in the launcher.
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
I'm developing an Android app with a button that when that button pressed I want to hide WhatsApp launcher icon. How can I do that?
I know that I should use PakageManager but I have no idea how to use it. I found this code but I have no idea how to use it:
ComponentName componentToDisable = new ComponentName("target package name",
"target launcher activity");
getPackageManager().setComponentEnabledSetting(
componentToDisable,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
That is not possible, outside of some security flaw that I don't know of. Your app can disable your own app's components; your app cannot disable the components of other apps.