Android hidden software icon

Source: Internet
Author: User

If your app needs to hide icons, the next paragraph in this article might help you.

Before you find this article, you may have tried the following solutions:

1,androidmanifest.xml file in the Intent-filter of the entry activity to remove <category android:name= "Android.intent.category.LAUNCHER "/> or change launcher to default

2, add the following code to the program

Show Picture:

Packagemanager p = Getpackagemanager ();

P.setcomponentenabledsetting (Getcomponentname (), packagemanager.component_enabled_state_enabled, Packagemanager.dont_kill_app);

Hide icon:

Packagemanager p = Getpackagemanager ();

P.setcomponentenabledsetting (Getcomponentname (), packagemanager.component_enabled_state_disabled, Packagemanager.dont_kill_app);

packagemanager.component_enabled_state_enabled//Show app icon

packagemanager.component_enabled_state_disabled//Hide app icon

I use these two values to show and hide the application icon has a problem, hidden will not be able to display the app icon, in the settings of all applications can not be found;

Packagemanager.component_enabled_state_default//Show app icon

Packagemanager.component_enabled_state_disabled_user//Hide app icon

It is not a problem to have the value of the parameter as these two values, it is recommended to use these two values,

3, remove android:icon= "@drawable/ic_launcher" in the resources Ah, and so on ...

But once you've tried every method, you find that it works, but it creates other problems.

Here's an explanation of the first one,

If you remove the <category android:name= "Android.intent.category.LAUNCHER"/>, it means that the app does not start the portal, which really solves the effect of not showing the icon, But in that case our app won't work either. Headache ~ ~ ~

Second, let's take a look at the instructions on Android Developer:

public static final int component_enabled_state_disabled

Flag for setapplicationenabledsetting (String, int, int) and setcomponentenabledsetting (componentname, int, int.): this Component or application have been explicitly disabled, regardless of what it have specified in its manifest.

This means that even if you declare this component or application in manifest, they are not available when you set it to component_enabled_state_disabled. That is, if you set this up in Mainactivity, the app icon won't show and the app won't run.

Well, this is also not feasible ~ ~ ~

The third kind does not say, I think is the cornered practice.

——————————— Split Line —————————————

Next I want to say that this method can hide the icon, the same can also be started normally run.

In the manifest entry activity inside Intent-filter set <data></data> elements.

Like what:

<data android:host= "authactivity" android:scheme= "Com.android.example"/>

Note that Android:scheme is case-sensitive and must start with a lowercase letter

That is, this mainactivity can respond to specific Intent that are URI com.android.example://authactivity

But why does the app not show icons when you join this?

Because we declare the app's entry activity to be activated by the intent that receives the hermit, it will naturally not show the icon.

Well, if you need to display the icon and must respond to the above URI, then we can add a intent-filter tag to the activity and move the data element to the new tag. This allows the application to display both an icon and a specific URI.

Android hidden software icon

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.