Android Instance-Create a shortcut for the program (not tested)

Source: Internet
Author: User

Results :

1. Because only Xiaomi mobile phone, no Samsung mobile phone, unable to test. If any God has tested it, remember M i oh, thanks.

Instance code:

1 UnitUnit1;2 3 Interface4 5 uses6 system.sysutils, System.types, System.uitypes, system.classes, System.variants,7 FMX. Types, FMX. Controls, FMX. Forms, FMX. Graphics, FMX. Dialogs, Fmx.stdctrls,8 FMX. controls.presentation;9 Ten type OneTForm1 =class(Tform) A Label1:tlabel; - Button1:tbutton; -     procedureButton1Click (sender:tobject); the   Private -     {Private Declarations} -    Public -     {Public Declarations} +   End; -  + var A Form1:tform1; at  - Implementation - uses -   //Androidapi.JNI.JavaTypes, the great god of the Internet said to introduce, but I didn't see where to use -   //FMX. Platform.android, -   //AndroidApi.Jni.App, inAndroidAPI.jni.OS,//need to introduce -Androidapi.JNI.GraphicsContentViewText,//need to introduce toAndroidapi.jnibridge,//need to introduce +Androidapi.helpers;//need to introduce - {$R *.FMX} the {$R *. NMXHDPIPH.FMX ANDROID} *  $ procedureTform1.button1click (sender:tobject);Panax Notoginseng {$IFDEF ANDROID} - var the shortcutintent:jintent; + addintent:jintent; A Wiconidentifier:integer; the Wiconresource:jintent_shortcuticonresource; + {$ENDIF} - begin $   {$IFDEF ANDROID} $Shortcutintent: =TJIntent.JavaClass.init (Sharedactivitycontext, sharedactivitycontext.getclass); - shortcutintent.setaction (TJIntent.JavaClass.ACTION_MAIN); -  theAddintent: = tjintent.Create; -Addintent.putextra (TJIntent.JavaClass.EXTRA_SHORTCUT_INTENT, Tjparcelable.wrap (shortcutintent asilocalobject). Getobjectid));Wuyi Addintent.putextra (TJIntent.JavaClass.EXTRA_SHORTCUT_NAME, stringtojstring (Application.title)); theAddintent.setaction (Stringtojstring ('Com.android.launcher.action.INSTALL_SHORTCUT')); -  Wu   //Get icon Resource Identifier//Please change the underlined red section to your project name, others do not need to be modified.  -Wiconidentifier: = SharedActivity.getResources.getIdentifier (Stringtojstring ('Ic_launcher'), Stringtojstring ('drawable'), Stringtojstring ('Com.embarcadero. Project1 ')); AboutWiconresource: =TJIntent_ShortcutIconResource.JavaClass.fromContext (Sharedactivitycontext, wiconidentifier); $   //set icon for shortcut -Addintent.putextra (TJIntent.JavaClass.EXTRA_SHORTCUT_ICON_RESOURCE, Tjparcelable.wrap (wiconresource asilocalobject). Getobjectid)); -  - Sharedactivitycontext.sendbroadcast (addintent); A   {$ENDIF} + End; the  - End.

Android Instance-Create a shortcut for the program (not tested)

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.