Android Question Install intent no longer working

nibbo

Active Member
Licensed User
Longtime User
I have an install apk intent which has been working for years but now fails.
I guess this is another Android 10 issue?

B4X:
Dim i As Intent
i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirDefaultExternal, "AppName.apk"))
i.SetType("application/vnd.android.package-archive")
StartActivity(i)

When the above executes I get the error below:
B4X:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///storage/emulated/0/Android/data/******.****/files/AppName.apk typ=application/vnd.android.package-archive flg=0x20000 }


Thanks
Nibbo
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

nibbo

Active Member
Licensed User
Longtime User
Thanks #Geezer and #DonManfred but that makes no difference. Still the same error.
If I log File.DirDefaultExternal & RuntimePermissions.GetSafeDirDefaultExternal they both show the same file destination.
 
Upvote 0

nibbo

Active Member
Licensed User
Longtime User
OK, maybe one step forwards and two steps back...
I think I needed to increase the target SDK which was still set to 22 for this app. I have increased it to 26.
I now get:
B4X:
android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/Project.Title/files/App.apk exposed beyond app through Intent.getData()
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
OK, maybe one step forwards and two steps back...
I think I needed to increase the target SDK which was still set to 22 for this app. I have increased it to 26.
I now get:
B4X:
android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/Project.Title/files/App.apk exposed beyond app through Intent.getData()
Increase it to 28
 
Upvote 0

nibbo

Active Member
Licensed User
Longtime User
OK, found something on StackOverflow that suggested replacing 'file://' with 'content://'.
This seems to have got to the next error which is now 'Problem parsing the package' but I think we have got past the original problem and the install intent is now starting OK.
Will investigate further and post back what I find; thanks for all of your help.
 
Upvote 0
Top