Several implementations of Android app with multiple icons

Source: Internet
Author: User

    • This article tags: Android Activity-alias
    • New requirements My app will have multiple icon portals. Finally activity-alias , there are several ways to implement multiple icons.
1. Multi Activity + intent-filter mode

Because launcher scans the app for labels that contain the following Intent-filter attributes, some will add them to the desktop.
So just add the following tags to the activity that you want added to your desktop.

<intent-filter>  <action android:name="android.intent.action.MAIN" />  <category android:name="android.intent.category.LAUNCHER" /></intent-filter>
2. Activity-alias mode

The first approach to the activity of the requirements is not possible, only by writing a few more portals Activity + jump parameters to solve the way, and the Activity-alias method can be a good solution to the problem.

Activity-alias, Android:name is the name you define for this activity, which you enter by clicking on this icon, in the code

Getintent (). Getcomponent (). GetClassName ()

You can get to that name, which targetActivity is the target activity after you click on the icon. The code above is written in the target activity, and the name we get is still the name we define. That's where you come in through this judgment.

<activity-alias    android:name="@string/altman"    android:exported="true"    android:icon="@drawable/speech_01"    android:label="@string/altman_app_name"    android:screenOrientation="landscape"    android:targetActivity="com.avatar.dialog.DialogActivity"    android:theme="@style/DialogActivityTheme" >    <intent-filter>        <action android:name="android.intent.action.MAIN" />        <category android:name="android.intent.category.LAUNCHER" />    </intent-filter></activity-alias>
3. Web tab-Add shortcut

This is only for special cases, such as when a UC browser creates a Web page label on the desktop and is a broadcast to the desktop app (launcher) about the action, the relevant action is as follows:

public static final String ACTION_ADD_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT";

Required Permissions:

<!-- 添加快捷方式 --><uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /><!-- 移除快捷方式 --><uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" /><!-- 查询快捷方式 --><uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />

Add icon

private void Addshortcut (String name) {Intent addshortcutintent = new Intent (action_add_shortcut); Do not allow duplicate creation of Addshortcutintent.putextra ("duplicate", false);//test is not based on the name of the shortcut to duplicate//should be based on the fast chain of intent to determine whether the repetition, that in Tent. extra_shortcut_intent field value//But the name is not the same, although some phone system will show a toast prompt repeat, will still establish a fast chain//on the screen when there is no space will prompt//Note: Repeated creation of the behavior Miui and three       Star phone is not the same, millet on the seemingly cannot repeat create Shortcut//name Addshortcutintent.putextra (intent.extra_shortcut_name, name); Icon Addshortcutintent.putextra (Intent.extra_shortcut_icon_resource, Intent.ShortcutIconResource.from       Context (Mainactivity.this, R.drawable.ic_launcher));       Set the Affiliate program Intent launcherintent = new Intent (intent.action_main);       Launcherintent.setclass (Mainactivity.this, Mainactivity.class);       Launcherintent.addcategory (Intent.category_launcher);       Addshortcutintent. PutExtra (Intent.extra_shortcut_intent, launcherintent); Send broadcast SendbroaDcast (addshortcutintent); }

written at the end: for Freedom look outside the world, and it this line, not to go to Google data, finally, Amway some speed agent.

Accelerator recommendations Free Solutions Payment Plan Official website
A Red apricot accelerator Free program is not available, stable high-speed Enter 80 percent coupon code WH80, annual pay only 80 yuan/year Website Direct
Azumino Accelerator Best use of foreign trade VPN Minimum ¥30/Month Website Direct
Loco Accelerator Free 2 hours per day Minimum ¥15/Month Website Direct

This article tags: Android Activity-alias

Turn from SUN's BLOG-focus on Internet knowledge, share the spirit of the Internet!

Original Address : Several implementations of Android app multiple icons

Related reading : Chrome extension Stylish: "Skin-changing" with one click to not like a website

Related reading : "Integrating QQ music, NetEase cloud music and shrimp music resources" with chrome extension listen 1 "

Related reading : " 8" new tab "chrome Extensions: teach you to play the New tab page with a sneak"

Related reading : "7 Practical Chrome Extensions recommended: help you improve your chrome experience"

Related reading : "No extension is not Chrome: 15 Premium Chrome Extensions recommended for everyone"

Related reading : the best experience for Web browsing with 12 no less chrome extensions

Related reading : "5 Chrome extensions that bring happiness"

Related reading : "Use case for Palette class in Android: Color adaptive Toolbar"

Related reading: What git can do, how it differs from SVN in depth

Related reading: "Share some of the most useful, user-friendly, and feature-rich Google Chrome Extensions for developers"

Related reading: a lot of brief encounter tools or websites that share some of the actual Android development process

related reading:"I am a G powder, has been concerned about Google, recently Google has some little gestures, probably a lot of people do not understand"

related reading:"machine learning leads to technological innovation in the field of cognition, so how can the SaaS industry be changed by machine learning?" 》

related reading:"VPS Tutorial Series: DNSMASQ + DNSCrypt + SNI Proxy smooth access to Google configuration tutorial"

related reading: most useful: 2017 the latest way to Google, Facebook

related Blog:sun ' S BLOG -Focus on Internet knowledge and share the spirit of Internet! Go and see:www.whosmall.com

Original address: http://whosmall.com/?post=446

This article anderson/jerey_jobs

Blog Address: http://jerey.cn/
Jane's book Address: Anderson Big yard slag
GitHub Address: Https://github.com/Jerey-Jobs

Several implementations of Android app with multiple icons

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.