Android Question sdk 31 problem with pm.GetApplicationIntent(AppName)

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
hi

i have this sub

B4X:
Sub CheckAppInstalled(AppName As String) As Boolean
    Dim pm As PackageManager
    Dim in As Intent
    
    in = pm.GetApplicationIntent(AppName)
    If in.IsInitialized Then
        Return True
    Else
        Return False
    End If
    
End Sub

in sdk 30 works perfectly
in sdk 31 it does not - always returns false

how can i detect if an app is installed on the device ?
naturally i'm interested in sdk 31...

thanks
 

agraham

Expert
Licensed User
Longtime User
Do you ever search the forum? Searching for "check app installed" brings this up, amongst others.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Do you ever search the forum? Searching for "check app installed" brings this up, amongst others.
i do, so either i missed it or searched for the wrong search...
anyway thanks for the link - i'll try it...
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Do you ever search the forum? Searching for "check app installed" brings this up, amongst others.
did you read the restriction?
i want my app to be on google store so this is problem #1
i don't need such a wide useage, i'm not a "file manager"
i just need to check for one and one only app (also mine) so i think this alternative does not suite my needs - or does it?
just add this permission to manifest?
is there a way to check for only one specific app ?

i also read your sample for edge - not my path as i need to run a simple app

so how should i go now?
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
hold on,

if i try to run the app using intent and try cathch - so if the is NOT installed i will get the catch and if installed it will run?
it that so - i did use your sample and this will solve my problem...
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
tried this

B4X:
s = "myAppName"    
Try
        StartActivity(s)
    Catch
        MsgboxAsync("run error" & CRLF & LastException.Message, "my app")
        Log("error: " & LastException.Message)
    End Try

where s was the appname and then tries with the packagename
in both cases i got the catch error saying it was not found and in the name i got the combination of my calling app name and the target app name
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
got it to work

B4X:
Try
        Dim MyIntent As Intent
        MyIntent.Initialize(MyIntent.ACTION_MAIN, "")
        MyIntent.SetComponent("MyAppName/.main")
        StartActivity(MyIntent)
    Catch
        MsgboxAsync("run error" & CRLF & LastException.Message, "my app")
        Log("error: " & LastException.Message)
    End Try

the question is - are they using the same internaldir now or each uses its own ?
they show on task manager as one (the first) so maybe ?
 
Upvote 0
Top