Android Question is possible know if shortcut is created?

scsjc

Well-Known Member
Licensed User
Longtime User
Hello,
i'm test to create shortcuts from any app, and remove shortcuts... thats is perfect and work.
but i want know if is possible detect if a one shortcut are created???



This code is working fine in at Samsung S5

B4X:
codigo.CreateShortCut("MainShortcut","android.test.com/.main","iconmain.png")
codigo.CreateShortCut("extraShortcut","android.test.com/.main","iconextra.png")


B4X:
Sub Activity_Create(firsttime As Boolean)
    'checkea way
    Dim in As Intent
    in = Activity.GetStartingIntent
    If in.HasExtra("extraShortcut") And in.GetExtra("extraShortcut") = True Then
        msgbox("ExtraShortcut","")
        ....
        Return
    End If
.
.
.
end sub



B4X:
Sub CreateShortCut(iconame As String, packagename As String, iconoimage As String)
    Dim shortcutIntent As Intent
    shortcutIntent.Initialize("", "")
    shortcutIntent.SetComponent(packagename) ' Put the app package name here
    shortcutIntent.PutExtra(iconame, True)

    Dim In As Intent
    In.Initialize("", "")
    In.PutExtra("android.intent.extra.shortcut.INTENT", shortcutIntent)
    In.PutExtra("android.intent.extra.shortcut.NAME", iconame) ' Put you're application name here
    In.PutExtra("android.intent.extra.shortcut.ICON", LoadBitmap(File.DirAssets, iconoimage))
    In.Action = "com.android.launcher.action.INSTALL_SHORTCUT"

    Dim p As Phone
    p.SendBroadcastIntent(In)
    DoEvents
End Sub

Sub RemoveShortCut(iconame As String, packagename As String)
    Dim shortcutIntent As Intent
    shortcutIntent.Initialize("", "")
    shortcutIntent.SetComponent(packagename)
    shortcutIntent.PutExtra(iconame, True)

    Dim in As Intent
    in.Initialize("", "")
    in.PutExtra("android.intent.extra.shortcut.INTENT", shortcutIntent)
    in.PutExtra("android.intent.extra.shortcut.NAME", iconame)
    in.Action = "com.android.launcher.action.UNINSTALL_SHORTCUT"

    Dim p As Phone
    p.SendBroadcastIntent(in)
    DoEvents
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
I dont think that there is an event for this
 
Upvote 0
Top