Android Desktop shortcut jump to specified activity

Source: Internet
Author: User
<span id="Label3"></p><p><p>Androidmanifest.xml Application Main Portal Configuration:</p></p><p><p></p></p><pre name="code" class="html"><pre name="code" class="html"> <activity android:name= "com.*.cust.contacts.mainactivity" android:exported= "true" Android:label = "@string/app_name" android:screenorientation= "portrait" > <intent-filter> <action Android:name= "android.intent.action.MAIN"/> <!--custom action that can be applied within a call-to-<action by a custom action Android:name= "*.intent.action.shortcut"/> <category android:name= "android.intent.category.LAUNCHER"/ > <!--must Add this, or you won't be able to use custom action--- <category android:name= "android.intent.category.DEFAULT "/> </intent-filter> </activity></pre></pre><br>To create a shortcut:<p><p></p></p><p><p></p></p><pre name="code" class="java"><pre name="code" class="java"> Custom Action Intent Intent = new Intent ("*.intent.action.shortcut"); Bundle bundle = new Bundle (); The corresponding operation can be performed according to the passing parameters bundle.putstring ("needgoto", "*activity"); Intent.putextras (bundle); Create desktop shortcut Intent shortcutintent = new Intent ("com.android.launcher.action.INSTALL_SHORTCUT"); Whether to allow duplicate creation of Shortcutintent.putextra ("duplicate", true); Need to display the name shortcutintent.putextra (intent.extra_shortcut_name, getString (r.string.app_name_1)); Quick Picture parcelable icon = Intent.ShortcutIconResource.fromContext (getapplicationcontext (), r.drawable.ic_ launcher); Shortcutintent.putextra (intent.extra_shortcut_icon_resource, ICON); Click on the shortcut picture, run the program main entrance Shortcutintent.putextra (intent.extra_shortcut_intent, Intent); Send broadcast execution operation Sendbroadcast (shortcutintent);</pre></pre><br><br><p><p></p></p><p><p> Android Desktop shortcut jumps to specified activity </p> </p></span>

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.