Trying to install an APK found in DirAssets

jdiperla

Member
Licensed User
Longtime User
I am trying to install an APK I included in the file assets, but I am having trouble.

This is my code:

B4X:
Sub InstallLock()
Dim uri As String

        uri = "file://" & File.Combine(File.DirRootExternal, "lock.apk")
File.Copy(File.DirAssets,"lock.apk",File.DirRootExternal,"lock.apk")
i2.Initialize(i2.ACTION_VIEW, uri)
      i2.SetType("application/vnd.android.package-archive")
      StartActivity(i2)
'Msgbox(uri, "")
      End Sub

It keeps giving me a parse error or a file corrupt error. However, if I move the apk to the storage area manually and run it, it works fine. Suggestions?
 

derez

Expert
Licensed User
Longtime User
I added
B4X:
Dim i2 As Intent
and it works (with another application of course. Maybe the file is really corrupt)
 
Upvote 0

jdiperla

Member
Licensed User
Longtime User
Yes, I added that. The file is not corrupt. It wont do it for any file. I got it to work though by doing something very long and crazy. So I will just stick to that for the time being. Thanks though.
 
Upvote 0
Top