Android Code Snippet Add pinned shortcut

Discussion in 'Code Snippets' started by Erel, Aug 18, 2019.

  1. Erel

    Erel Administrator Staff Member Licensed User

    #AdditionalJar: androidx.core:core

    Sub RequestPinShortcut (id As String, icon As Bitmap, ShortLabel As Object)
    Dim ctxt As JavaObject
    Dim ShortcutManagerCompat As JavaObject
    Dim supported As Boolean = ShortcutManagerCompat.RunMethod("isRequestPinShortcutSupported"Array(ctxt))
    If supported Then
    Dim builder As JavaObject
    ""Array(ctxt, id))
    Dim in As Intent
    in.Initialize(in.ACTION_MAIN, "")
    in.SetComponent(Application.PackageName & "/.main"'lower case
    "requestPinShortcut"Array(ctxt, builder.RunMethod("build"Null), Null))
    End If
    End Sub

    Private Sub CreateIconFromBitmap(bmp As BitmapAs Object
    Dim ic As JavaObject
    Return ic.InitializeStatic("").RunMethod("createWithBitmap"Array(bmp))
    End Sub
    Depends on JavaObject. Request AndroidX SDK.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice