Use Cases and implementation methods for Android apps that do not display icons on the desktop after installation, androidapp

Source: Internet
Author: User

Use Cases and implementation methods for Android apps that do not display icons on the desktop after installation, androidapp

Recently, I am working on a IOV product for the company. because the company is good at the R & D of Automotive decoder, therefore, in addition to the OBD Protocol widely used in IOV products on the market, the diagnostic function of this product also uses some dedicated vehicle protocols to implement some special diagnostic functions, such as upgrading/downgrading windows, resetting to zero, and reading TPMS data streams. The company's idea is to treat these dedicated car diagnoses as a paid service for users, that is, users are free to use the diagnostic functions implemented based on the OBD protocol, if you want to use a special function implemented by the dedicated vehicle protocol, you need to pay for it in the form of the amount of money required for each function (I am not in favor of making money in this way, I think it is better to be free of charge ).

I am mainly responsible for the development of the Android APP in this IOV product. To meet the requirements of this product mentioned above, we are going to make the special function diagnostic programs of each car into subprograms one by one, that is to say, the reason why this method is used is:① There are many models on the market. The diagnostic procedures for the same special function of each model vary with the vehicle protocol. If all the programs are placed in one APP, the APP will inevitably be too large, it is not easy to maintain in the future. ② the original intention of providing these special functions is to cater to the needs of professional vehicle maintenance personnel and vehicle conversion enthusiasts (hereinafter referred to as "professional users, most common users may not use it, which makes it easier for users to download.

In order to prevent users from having various icons on their desktops after installing the sub-APK (I hate mobile phone desktops too messy), the user experience is too poor and the program portal can be concentrated on the master APK, you can only find some tips to disable these icons on the desktop. The specific implementation method is as follows:

1. Develop a main APP named opennoiconapp.apk. There is a button in it to open the sub-APP after clicking it. 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 (), "This sub-APP is not available, please download and install", * Toast. LENGTH_LONG ). show () ;}*/Intent intent = new Intent (); 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, "this sub-APP is not available, please download and install", Toast. LENGTH_SHORT ). show () ;}break; default: break ;}}
2、a subapp named noiconapp.apk (used for opening the primary APP). This APP is mainly used to display no icons on the desktop. To disable the desktop icon, you only need to modify the AndroidManifest. xml file. The details are as follows:
<? 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 =" 14 "android: targetSdkVersion = "14"/> <application android: allowBackup = "true" android: icon = "@ drawable/ic_launcher" android: label = "@ string/app_name" android: theme = "@ style/AppTheme"> <activity android: name = "com. example. noi Conapp. MainActivity "android: label =" @ string/app_name "> <intent-filter> <action android: name =" android. intent. action. MAIN "/> <! -- To do not display icons on the desktop, just comment out the following sentence in the Activity of the APP portal, or change the LAUNCHER below to DEFAULT. --> <! -- <Category android: name = "android. intent. category. LAUNCHER"/> --> </intent-filter> </activity> </application> </manifest>
3. The reason why the desktop icon is not displayed is as follows:

In general, when our APK is installed, the system will automatically create our APK program, system Launcher (system desktop application) the system automatically detects the package names of installed applications, parses the icons and names of these apps, and displays them in the Application List, once we set not to display the APK icon as above, the APK program will only be displayed in the "running" program list after running, rather than the icon and name on the desktop. If you only set the APP icon to be invisible and use the first method (the code I noted) to open the APP, it will not be successful, because after this setting, the package name will not be loaded to the Launcher at all, so through getPackageManager (). the Intent obtained by the getLaunchIntentForPackage () method is null.

4. Other examples:

A few days ago, I updated the latest Android APP of China Unicom's "mobile APP Department". I found that the newly added "network speed measurement" feature is actually a sub-APP, which is exactly the same method.

5. Example program:

Click Download.

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.