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 DonManfred but I have followed that thread and have the correct permissions bit in place.
My app now shows in the list of apps that can install unknown sources so that is all OK.
My intent looks exactly the same as post #2 in that thread also but I still get the error.
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.
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()
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()
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.