Examples and implementations of scenarios where Android app does not display icons on the desktop after installation

Source: Internet
Author: User

1, the development of a opennoiconapp.apk called the main app, inside a button to open the sub-app after clicking, the core jump code is as follows:

Public void onclick (View view)  {    switch  (View.getid ())  {     case r.id.btn_open_app:         /*          * intent intent = getpackagemanager ( ). Getlaunchintentforpackage (         *  " Com.example.noicontest "); if  (intent != null)  { //          * startactivity (Intent); } else {           * toast.maketext (Getapplicationcontext (),  "There is no such child app, please download the installation",          * toast.length_long). Show (); }          */        intent intent =  new intent ();    &nbSp;    componentname cn = new componentname ("Com.example.noiconapp", " Com.example.noiconapp.MainActivity ");         intent.setcomponent (CN);         intent.setaction ("Android.intent.action.MAIN");         try {             startactivityforresult (INTENT, RESULT_OK);         }  catch  (exception e)  {             toast.maketext (this,  "does not have the child app, please download the installation", Toast.length_short). Show ();         }        break;    default:         break;    }}


2, the development of a child app named NOICONAPP.APK (for the main app to open), the app is mainly implemented on the desktop does not display icons. If you want to not display the desktop icon only need to modify the Androidmanifest.xml file. The following are the details:

<?xml version= "1.0"  encoding= "Utf-8"? ><manifest xmlns:android= "http// Schemas.android.com/apk/res/android "package=" Com.example.noiconapp "android:versioncode=" 1 "android:versionname= "1.0"  ><uses-sdk    android:minsdkversion= "    android": targetsdkversion= " /><application    android:allowbackup="    "true"   android:icon= "@drawable/ic_launcher"     android:label= "@string/app_name"      android:theme= "@style/apptheme"  >    <activity         android:name= "Com.example.noiconapp.MainActivity"          android:label= "@string/app_name"  >         <intent-filter>            <action  android:name= "Android.intent.Action. MAIN " />            <!--  To not display the icon on the desktop, simply comment out the following sentence in the app entry activity, or change the following launcher to default  -->             <!-- <category android:name= " Android.intent.category.LAUNCHER " /> -->        </ Intent-filter>    </activity></application></manifest>


3, the above settings can make the desktop icon does not display the reason:

In general, when our apk is installed, the system will automatically create our APK program, System Launcher (System desktop application) will automatically detect the system has installed the application software package name, and then the app's icon and name resolved to appear in the application list, Once we set the APK icon to not appear as above, the APK program will only appear in the "Running" list of programs after running, instead of displaying the icon and name on the desktop. If you just set the app icon to be invisible and use the first way (the code I commented on) to open the app, it won't be successful, because after this setting, the package name is not loaded to launcher at all, so through Getpackagemanager (). The Getlaunchintentforpackage () method obtains a intent of NULL.

Examples and implementations of scenarios where Android app does not display icons on the desktop after installation

Related Article

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.