POST
A quick way to hide app icon on andorid desktop
Here introduces a quick way to hide the android app icon on the desktop. Although it isn’t a common case on the development or usage of android app, it deserves pay a little bit time reading for anyone who want to realize it.
The code implementation
The method is to add a <data></data>
property on your app’s AndroidManifest.xml
.
Below is a example.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.hideapplication02">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HideApplication02">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- hide application icon start -->
<data android:host="mainactivity" android:scheme="com.example.hideapplication02"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Comments
The key points are:
- App’s entry activity is declared to be started by receiving implicit intent, so the icon will not be displayed naturally.
- For the
data
property declaring, theandroid: scheme
must have been defined explicitly. - Property value needs to start with a lowercase letter.
- To call the app, need to use URI, the formate is
scheme://host: port/path
.
Therefore, for above example, the URI iscom.example.hideapplication02://mainactivity
. - The caller needs to add below code:
Uri uri = Uri.parse("com.example.hideapplication02://mainactivity");
Intent intent = new Intent(null, uri);
startActivity(intent);