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;

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android studio ndk开发遇到的问题
  2. android Ant批打包学习(一):生成没有签名
  3. Android中的DownloadManager
  4. Android(安卓)Studio获取SHA1值
  5. ANDROID Porting系列三、Build Cookbook
  6. Android(安卓)中文 API (20) —— DatePick
  7. 基于Android(安卓)tess-two工程的数字识
  8. Android使背景灯(Brightness)高亮的方法
  9. Android的CTS测试
  10. 【Android】View绘制过程分析之draw