App Shortcuts for Android desktop

Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="font-size: 16px;">This article describes how to implement an App's shortcut to create an app on the Anroid desktop during app Development. It consists of two steps:</span></p></p><p><p><span style="font-size: 14px;">one, declare the relevant permissions in Androidmanifest.xml:</span></p></p><p><p><span style="font-size: 14px;"> <span style="color: #ff0000; font-size: 16px;"><uses-permission android:name= "com.android.launcher.permission.INSTALL_SHORTCUT"/></span> </span></p></p><p><p><span style="color: #000000; font-size: 14px;">second, the code is implemented as Follows:</span></p></p><p style="text-align: left;"><span style="color: #000000;"><span style="color: #ff0000; font-size: 16px;"><span style="color: #ff0000; font-size: 16px;">Intent addintent=new Intent ("com.android.launcher.action.INSTALL_SHORTCUT");</span></span><br><span style="color: #ff0000; font-size: 16px;"><span style="color: #ff0000; font-size: 16px;">parcelable icon=intent.shortcuticonresource.fromcontext (mainactivity.this,r.drawable.sms);</span></span><br><span style="color: #ff0000; font-size: 16px;"><span style="color: #ff0000; font-size: 16px;">Intent myintent=new Intent (mainactivity.this,mainactivity.class);</span></span><br><span style="color: #ff0000; font-size: 16px;"><span style="color: #ff0000; font-size: 16px;">Addintent.putextra (intent.extra_shortcut_name, "shortcut");</span></span><br><span style="color: #ff0000; font-size: 16px;"><span style="color: #ff0000; font-size: 16px;">Addintent.putextra (intent.extra_shortcut_icon_resource, ICON);</span></span><br><span style="color: #ff0000; font-size: 16px;"><span style="color: #ff0000; font-size: 16px;">Addintent.putextra (intent.extra_shortcut_intent,myintent);</span></span><br><span style="color: #ff0000; font-size: 16px;"><span style="color: #ff0000; font-size: 16px;">sendbroadcast (addintent);</span></span></span></p><p style="text-align: left;"><p style="text-align: left;"><span style="color: #000000; font-size: 14px;">In this way, you have implemented a shortcut to the Android desktop for generating apps in your app.</span></p></p><p style="text-align: left;"><p style="text-align: left;"></p></p><p style="text-align: left;"><p style="text-align: left;"><span style="color: #000000; font-size: 14px;">Life is short, happiness is not every day, cherish the Present.</span></p></p><p><p>App Shortcuts for Android desktop</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.