Home Screen Shortcuts

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,

I have the following code below that allows me to create a shortcut on the home screen. However when it creates the shortcut it displays a toast message saying the shortcut was created.

Is there a way to make it so that the message is not displayed?

B4X:
        Dim PrefMgr As PreferenceManager
    If PrefMgr.GetBoolean("shortcutinstalled") Then
        Return
    End If
    
    Dim shortcutIntent As Intent
    shortcutIntent.Initialize("", "")
    shortcutIntent.SetComponent("my.app/.main") ' Put the app package name here
    
    Dim In As Intent
    In.Initialize("", "")
    In.PutExtra("android.intent.extra.shortcut.INTENT", shortcutIntent)
    In.PutExtra("android.intent.extra.shortcut.NAME", "My ShortCut") ' Put you're application name here
        In.PutExtra("android.intent.extra.shortcut.ICON", LoadBitmap(File.DirAssets, "app_icon_1.png")) ' If you have the icon file in the assets, you just need any bitmap here. Best is 72x72 pixels because launchers do not scale. You might want to experiment a little bit with size
    
    In.Action = "com.android.launcher.action.INSTALL_SHORTCUT"
    
    Dim p As Phone
    p.SendBroadcastIntent(In)
    'DoEventsNow
    PrefMgr.SetBoolean("shortcutinstalled", True)
 
Top