KMarb 5 Posted December 28, 2022 What's the best way to install a shortcut on android home screen when I install my app? If it matters I'm not using the play store. I'm using Delphi 11.1. I found some code (that was pretty old) but it is not working. My slight modifications of it is below: procedure addShortcut (const AppID : string); var ShortcutIntent: JIntent; addIntent: JIntent; wIconIdentifier : integer; wIconResource : JIntent_ShortcutIconResource; begin 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')); //'com.embarcadero.HeaderFooterApplication' // get icon resource identifier wIconIdentifier := SharedActivity.getResources.getIdentifier(StringToJString('ic_launcher'), StringToJString('drawable'), StringToJString (AppID)); // if the app name change, you must change the package name 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); end; Share this post Link to post