Hide installed app in android - android

i want to hide the installed app by another app in android application, lets say user has installed 3rd party app called Skype, Watsapp, facebook etc...
is there a way we can hide and show them upon click of a button from another app?. i tried below code. No luck, nothing happened to my launcher
PackageManager packageManager = context.getPackageManager();
ComponentName componentName = new ComponentName(context,
LauncherActivity.class);
packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
But here i was not getting how to hide a particular application?, i also followed these SO link
but i could not get to know how to hide a perticular application.

To hide/unhide an app, your app need to be the DevicePolicyManager. You can find more information about the device policy manager at http://developer.android.com/reference/android/app/admin/DevicePolicyManager.html and you may need to use https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#setApplicationHidden(android.content.ComponentName,%20java.lang.String,%20boolean)
DevicePolicyManager dpm =
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName ownerComponent = new ComponentName(context, DeviceAdminReceiverImpl.class);
boolean newHiddenValue = true;
dpm.setApplicationHidden(ownerComponent, packageName, newHiddenValue);

Related

how can i recall a hidden app from phone dialer?

My Final project requires that app must be hidden,and never opened again unless entering some code in phone dialer (ex: *123#) can you help me guys to do that task?
This is a bit tricky and it has its up and downs, but what you need to do basically is:
On app install, you need to programmatically disable the app Icon so you cannot open it manually.
Have a BroadcastReceiver registered with the PROCESS_OUTGOING_CALLS intent filter (don't forget to set the uses-permissions).
In the receiver, listen for every dialed number and when it matches yours you need to activate the App Icon again and then you start the activity with possibly extra data to handle it later.
After processing the data in your activity remember to deactivate the icon again.
To programmatically disable the icon use:
PackageManager packageManager = getPackageManager();
ComponentName componentName = new ComponentName(this, MainActivity.class);
packageManager.setComponentEnabledSetting(
componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP
);
To enable it:
PackageManager packageManager = context.getPackageManager();
ComponentName componentName = new ComponentName(context, MainActivity.class);
packageManager.setComponentEnabledSetting(
componentName,PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP
);
In your receiver to get the dialed number you need to use:
if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
// Validate and start your activity here
// To start an activity from a receiver you need to use the flag FLAG_ACTIVITY_NEW_TASK in your intent
}
Note: After hiding the icon programmatically you might want to finish() the activity so it closes automatically at first run.
P.S I have a working sample of this, so rest assured as I have tested it actually works, sadly I cannot spoon feed you in your final project. Don't hesitate to ask anything tho. Good luck
There is no such functionality in Android. You may be able to do it with a custom home screen, but there is no "hide this app" functionality in the default launcher.

android hide app icon programmatically just works in my packagename

This code works and hides my application icon:
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName("myPackageName", "MyLauncherClass");
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
But I need hide another application icon.
When i replace myPackageName and MyLauncherClass with another application package name and launcher class, app force closed.
This means that i can hide my app icon only?
This means that i can hide my app icon only?
Correct. There may be some options for doing this as a device owner app, but ordinary apps cannot disable other apps.

Android Auto - launch third party app from within my app?

Is it possible to launch any third party application from my application on Android Auto
I couldn't find anything mentioned on this anywhere.
Note: Please note "Android Auto" (Car) words here. I am not asking for android mobile application.
Idea of android auto is completely different from what you are trying to do.
Android auto provides a platform where it has done the basic things with a good user interface making sure not to distract user much.
All that you need to do is provide services which this platform can use.
As of now you can provide Music and Messaging services which are compatible with android auto.
You can launch applications code something like
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.example.youpackage", "com.example.LauchActivity");
startActivity(intent);
And if you want get all possible application list for launch.code :
Declare you intent and add value you want pass
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
boolean isIntentSafe = activities.size() > 0;
if (isIntentSafe) {
startActivity(mapIntent);
}
And another way to start you specific application
PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.example.package");
startActivity(intent);

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