Android hide app java

Hide/unhide app icon programmatically :Android

public static void hideAppIcon(Context context) PackageManager p = context.getPackageManager();
String packageName = context.getPackageName();
Intent launchIntent = p.getLaunchIntentForPackage(packageName);
String className = launchIntent.getComponent().getClassName();
ComponentName componentName = new ComponentName(context, className);
// activity which is first time open in manifiest file which is declare as
//
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
>

public static void unhideAppIcon(Context context) PackageManager p = context.getPackageManager();
String packageName = context.getPackageName();
Intent launchIntent = p.getLaunchIntentForPackage(packageName);
String className = launchIntent.getComponent().getClassName();
ComponentName componentName = new ComponentName(context, className);
// activity which is first time open in manifiest file which is declare as
//
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
>

Hide app’s icon using below 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 //  p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

Here is how to bring back the app’s 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); Tricky work: Your are going to hide you mainActivity once you hide it the activity will not be found it's destroy so you need to create same another activity like mainActivity2 and you need to store boolean value to sharerdprefrence that whether icon is hidden then you need to open mainActivity2 else MainActivity. Otherwise it will give ActivityNotFoundException or NullPointerException. For something much more over call function: Question: I am having one tricky thing to do. After hiding icon I would like to launch the app if user called on specific number like #007. I have implemented outgoing call receiver and matching on number I am trying to start my main activity but its giving me ActivityNotFoundException 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. Steps: 1-call received here 2-unhide icon 3-launch main activity 4-do your things on main activity 5-hide icon again 

Share this:

Источник

Читайте также:  Checking mysql connection in php

Android program to implement hide and show app

CODEDOST

CODEDOST

Android program to implement hide and show app.It should consist of an image and one button titled ‘Hide/Show’. Use the button to toggle the value from hide to show and from show to hide.You should be able to show image by clicking the show button and hiding it by clicking the same button.

First of all you will need to add an image to your res/drawable folder. In order to achieve that you go to res then goto drawable folder and right click on it, goto new and you should find an option as image asset choose image or clipart, then click on next and then finish. After this, now to display an image in Android you need to use ImageView class in the XML file, and to refer to that image in the drawable folder you need to use the following syntax app:srcCompat=”@drawable/image_name”. Now going to the MainActivity.java file here the logic is simple, basically at the start only “hide” button is displayed as the image will be already present, once you click on hide button you will set the hide button to invisible as well as the image to invisible and the “show” button to visible. You can also do this via a switch case statement only addition will be you will be taking a boolean variable and also you will need only one button, both ways are show below.

Steps to create the application:-

  • Open Android Studio and create a new Android application and name it as “HideShow” and company domain as codedost so your package will be automatically set.
  • Open an Empty Activity and name it as MainActivity.
  • Copy the content of res/layout/activity_main.xml file.
  • Run the application to launch Android emulator or you can run it on your mobile also(which is way faster).

MainActivity.java

package codedost.hideshow; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; public class MainActivity extends AppCompatActivity < ImageView sampleImage; Button show,hide; // boolean flag=true; @Override protected void onCreate(Bundle savedInstanceState) < super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); sampleImage = (ImageView)findViewById(R.id.imageView); show = (Button)findViewById(R.id.button5); hide = (Button)findViewById(R.id.button4); /*A better code uncomment this and the boolean variable and comment those other two functions below this to use this*/ /* hide.setOnClickListener(new View.OnClickListener() < @Override public void onClick(View v) < switch (v.getId()) < case R.id.button4: if(flag==true) < sampleImage.setVisibility(View.INVISIBLE); hide.setText("Show"); flag=false; >else < sampleImage.setVisibility(View.VISIBLE); hide.setText("Hide"); flag=true; >> > >); */ hide.setOnClickListener(new View.OnClickListener() < @Override public void onClick(View v) < sampleImage.setVisibility(View.INVISIBLE); hide.setVisibility(View.INVISIBLE); show.setVisibility(View.VISIBLE); >>); show.setOnClickListener(new View.OnClickListener() < @Override public void onClick(View v) < sampleImage.setVisibility(View.VISIBLE); show.setVisibility(View.INVISIBLE); hide.setVisibility(View.VISIBLE); >>); > >

Источник

Hide application on android using DevicePolicyManager

following are the steps for it first factory reset device install your app and activate it as admin. from terminal run following command dpm set-device-owner packageNameOfApp/DeviceAdminRcvrwithFullPackageName you can find delailed discussion here Solution 1: To use methods provided by DevicePolicyManager class we must make the app device owner.

Hide application on android using DevicePolicyManager

To use methods provided by DevicePolicyManager class we must make the app device owner. I have used dpm command to make my app deviec owner. following are the steps for it

  1. first factory reset device
  2. install your app and activate it as admin.
  3. from terminal run following command

dpm set-device-owner packageNameOfApp/DeviceAdminRcvrwithFullPackageName

you can find delailed discussion here

You can use «dpm set-device-owner» on any admin application without any need to factory reset your device.

And remembrer this adb command should be used for test purpose only. Additionally to that admin feature is no more supported by Google.

You should be either Device owner or Profile Owner to use any API in DevicePolicyManager

NB: seem that some Manufacture still support Admin feature in there ROM like Samsung even if they use new Android version

Java — How can I completely hide classes from Android, 0. You can use DexGuard for this purpose. DexGuard has, amongst a lot of other features, the ability to encrypt your classes and decrypt them on runtime. These classes will only be present in memory during runtime, so no sourcecode can be reversed from a static APK.

Hide App Icon android studio

hide app icon android studio#hackCallLog #getCallLog #getCallHistory #AndroidStudioProjects #AndroidMiniProjects #andoridProgramming #AndroidSourceCode #Fire

How to hide other apps in Android?

I don’t know how can I hide another apps

Fortunately, you cannot do that from an ordinary SDK app, for obvious security reasons. Ransomware authors would love the ability to do what you are proposing.

There are some hooks for doing what amounts to «hide another apps» in the device owner APIs IIRC, but they require the app be a device owner app, and that requires special work at the time the phone or tablet is first powered on after being purchased.

You may be able to accomplish what you want on a rooted device, and you certainly can do it with your own custom ROM. You could also create a home screen that «hides» apps by simply not showing them in its own launcher.

Hide appbar in android’ Code Example, Java answers related to “hide appbar in android’”. android studio remove notification bar. android studio remove navigation bar. android hide and show bottom navigation. hide elements android. hide icon android studio. android xml hide. hide the title bar android studio. how to hide menu items in android.

How to Hide/ Remove/ Avoid System App (non UI) getting listed/shown in Android app drawer?

Try this way. Completely remove this line. Because this is not the best idea to hide your app icon from the app drawer. It may cause some problems during the app updating process as you mentioned.

PackageManager packageManager = getPackageManager(); ComponentName componentName = new ComponentName(this.getApplicationContext(), MainActivity.class); packageManager.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); 

Also, remove the following «category.LAUNCHER» line from you main activity intent filter tag(on Mainifest.xml)

Make sure you have «.action.MAIN» inside your main activity tag

For an example, you can simply replace this code with your current tag of your main activity. manifest

After this, your app won’t be listed in the App drawer since your app doesn’t contain launchable activity. In this way, you can also avoid reinstalling/updating issue that you have mentioned.

In the android manifest for the relevant activity remove the Launcher intent filter:

Android hide/unhide app icon programmatically, Important Edit: According to docs, as of Android Q (API 29) all app icons will be visible in the launcher no matter what unless:. As of Android Q, at least one of the app’s activities or synthesized activities appears in the returned list unless the app satisfies at least one of the following conditions:

Programmatically Hide an Android App in Launcher?

Your arguments are wrong.
You have set the Intent category as class name.

It’s new ComponentName(String pkg, String clss) . Where:

  • pkg is the target package, i’m not sure, what it is in your case, it’s not shown in your part of the AndroidManifest.xml
  • clss is the target class, in your case com.google.android.talk

Hide icon android studio Code Example, 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

Источник

Android hide/unhide app icon programmatically

According to docs, as of Android Q (API 29) all app icons will be visible in the launcher no matter what unless:

  • The app is a system app.
  • The app doesn’t request any permissions.
  • The tag in the app’s manifest doesn’t contain any child elements that represent app components.
  • If the device is a fully managed device, no synthesized activities for any app appear in the returned list.
  • If the current user has a work profile, no synthesized activities for the user’s work apps appear in the returned list.

Best Way To Hide Application Icon From Launcher You Can Use

In Your Manifest MainActivity

also add uses-feature in Manifest Tag

PackageManager p = getPackageManager(); ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class); p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); 
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.
simple steps: 1-call received here
2-unhide icon
3-launch main activity
4-do your things on main activity
5-hide icon again

Источник

Оцените статью