• 老外写的在桌面添加快捷方式(DELPHI XE5 ANDROID)


    Uses
    Androidapi.JNI.GraphicsContentViewText, FMX.Helpers.Android,
    Androidapi.JNI.JavaTypes, FMX.Platform.Android, AndroidApi.JniBridge, AndroidApi.Jni.App,
    AndroidAPI.jni.OS;

    procedure TForm1.FormCreate(Sender: TObject);

    {$IFDEF ANDROID}
    var
    ShortcutIntent: JIntent;
    addIntent: JIntent;
    wIconIdentifier : integer;
    wIconResource : JIntent_ShortcutIconResource;
    {$ENDIF}
    begin
    {$IFDEF ANDROID}

    ShortcutIntent := TJIntent.JavaClass.init(SharedActivityContext, SharedActivityContext.getClass);
    ShortcutIntent.setAction(TJIntent.JavaClass.ACTION_MAIN);

    addIntent := TJIntent.Create;
    addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_INTENT, TJParcelable.Wrap((shortcutIntent as ILocalObject).GetObjectID));

    // here we need to cast the intent as it’s not done in delphi by default, not like java

    addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_NAME, StringToJString(Application.Title));
    addIntent.setAction(StringToJString('com.android.launcher.action.INSTALL_SHORTCUT'));
    // get icon resource identifier


    wIconIdentifier := SharedActivity.getResources.getIdentifier(StringToJString('ic_launcher'),
    StringToJString('drawable'), StringToJString('com.embarcadero.HeaderFooterApplication'));

    // if the app name change, you must change the package name

    //只适用于HeaderFooter,其他的要改下('com.embarcadero.HeaderFooterApplication')。

    wIconResource := TJIntent_ShortcutIconResource.JavaClass.fromContext(SharedActivityContext, wIconIdentifier);

    // set icon for shortcut
    addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_ICON_RESOURCE, TJParcelable.Wrap((wIconResource as ILocalObject).GetObjectID));

    SharedActivityContext.sendBroadcast(addIntent);

    {$ENDIF}
    end;

  • 相关阅读:
    【BZOJ4676】Xor-Mul棋盘 拆位+状压DP
    【BZOJ4688】One-Dimensional 矩阵乘法
    【BZOJ4704】旅行 树链剖分+可持久化线段树
    【BZOJ4709】[Jsoi2011]柠檬 斜率优化+单调栈
    【BZOJ4711】小奇挖矿 树形DP
    【BZOJ4715】囚人的旋律 DP
    【BZOJ4712】洪水 树链剖分优化DP+线段树
    服务器相关 HTTP 请求错误
    RSA算法
    公钥和私钥解释
  • 原文地址:https://www.cnblogs.com/happyhills/p/3548699.html
Copyright © 2020-2023  润新知