Android activity-alias multi-entry configuration, android entry activity

Source: Internet
Author: User

Android activity-alias multi-entry configuration, android entry activity

In the past, some applications used to generate two icons on the desktop. Some of these two icons are the portals of the same Activity and others are the portals of another Activity, how can this effect be achieved? When viewing the Android native javasclock program, you can see the implementation of this function, using activity-alias:

1. Syntax format

<activity-alias android:enabled=["true" | "false"]                android:exported=["true" | "false"]                android:icon="drawable resource"                android:label="string resource"                android:name="string"                android:permission="string"                android:targetActivity="string" >    . . .</activity-alias>

2. DeskClock applications

From the following configuration, we can see that this is the two portals of the same activity (Clock), and the two portals have the same name icon. What is the significance of this operation? You can see that activity-alias marks a category named android. intent. category. category _dock. This triggers the alias portal only when the android device is plugged in to the desktop Dock base.

<activity android:name="DeskClock"         android:label="@string/app_label"         android:theme="@style/DeskClock"         android:icon="@mipmap/ic_launcher_alarmclock"         android:launchMode="singleTask"         >     <intent-filter>         <action android:name="android.intent.action.MAIN" />         <category android:name="android.intent.category.DEFAULT" />         <category android:name="android.intent.category.LAUNCHER" />     </intent-filter></activity><activity-alias android:name="DockClock"         android:targetActivity="DeskClock"         android:label="@string/app_label"         android:theme="@style/DeskClock"         android:icon="@mipmap/ic_launcher_alarmclock"         android:launchMode="singleTask"         android:enabled="@bool/config_dockAppEnabled"         >     <intent-filter>         <action android:name="android.intent.action.MAIN" />         <category android:name="android.intent.category.DEFAULT" />         <category android:name="android.intent.category.DESK_DOCK" />     </intent-filter></activity-alias>

Activity-alias determines the activity connected to the portal by specifying targetActivity, change a different label (ClockAlias) and icon (chrysanthemum) for the program, and replace the category of the Dock base, as shown in the lower code configuration.

<activity-alias android:name="DockClock"         android:targetActivity="DeskClock"         android:label="@string/app_second_label"         android:theme="@style/DeskClock"         android:icon="@mipmap/entrance"         android:launchMode="singleTask"         >     <intent-filter>         <action android:name="android.intent.action.MAIN" />         <category android:name="android.intent.category.DEFAULT" />         <category android:name="android.intent.category.LAUNCHER" />     </intent-filter></activity-alias>

After the configuration is modified, the dual portal icon on the android device can be implemented. You can click the two icons to enter the javasclock program. The specific effect is shown in.



Reprinted please indicate the source: http://blog.csdn.net/l2show/article/details/46828391


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.