Android Question Load another app from within my app.

tsteward

Well-Known Member
Licensed User
Longtime User
I gave up on this some time ago but would like to revisit it.
I want to create a button in my app that loads another app if installed on the device.
There are a lot of posts but I can't find a successful resolution.

This code complains on the last line that Intent should be initialized

B4X:
Dim pac As PackageManager
Dim in As Intent
in.Initialize(in.ACTION_MAIN, "")
in = pac.GetApplicationIntent("com.ecartek.en.kd")
StartActivity(in)

This is the folder I found on the device and in older versions of my app this worked but that was android target 28 and I just used
StartActivity(pac.GetApplicationIntent("com.ecartek.en.kd"))

App can be found here
 

Attachments

  • Screenshot 2022-11-13 180645.png
    Screenshot 2022-11-13 180645.png
    12.6 KB · Views: 111

drgottjr

Expert
Licensed User
Longtime User
things aren't like they used to be.
#1, you have to check for an initialized intent before you blindly use one.

#2, you are no longer allowed to interact with 3rd party apps automatically.
one solution is to add:
AddPermission(android.permission.QUERY_ALL_PACKAGES)
this will probably rule out publishing on play.

another solution is to list specifically apps that you need to access. in this case:

AddManifestText(
<queries>
<package android:name="com.ecartek.en.kd" />
</queries>
)

you can find more information here:

i pre-tested both solutions for your convenience.
 
Upvote 1

tsteward

Well-Known Member
Licensed User
Longtime User
things aren't like they used to be.
#1, you have to check for an initialized intent before you blindly use one.

#2, you are no longer allowed to interact with 3rd party apps automatically.
one solution is to add:
AddPermission(android.permission.QUERY_ALL_PACKAGES)
this will probably rule out publishing on play.

another solution is to list specifically apps that you need to access. in this case:

AddManifestText(
<queries>
<package android:name="com.ecartek.en.kd" />
</queries>
)

you can find more information here:

i pre-tested both solutions for your convenience.
Your a CHAMPION,
No seriously thank you for your help, I knew things had changed and will continue to.
Your time and help is appreciated. I used the last case as that's all I needed access to.

Regards
Tony Steward
 
Upvote 0
Top