Download and install

Vinians2006

Active Member
Licensed User
Longtime User
I want to create a button on my app where the user click and the app download the apk and tell the android to install it. How can I do it ?
I know how to download but how can I tell the android to install it with my own app being running ?
 

NJDude

Expert
Licensed User
Longtime User
After downloading the file you could install it like this:
B4X:
Dim iIntent As Intent 

iIntent.Initialize(iIntent.ACTION_VIEW, "file:///sdcard/MyAPK.apk")
iIntent.SetType("application/vnd.android.package-archive")

StartActivity(iIntent)
 
Upvote 0

Vinians2006

Active Member
Licensed User
Longtime User
Nice! But the download method on FTP dont require a URI, how can I convert an absolute FTP local path to a URI ? Im download things on the path File.DirInternal how can I access File.DirInternal using a URI format ?
See the download code:
B4X:
mFTP.DownloadFile("App.apk", _
         True, _
         File.DirInternal, _
         "App.apk")
Thanks
 
Last edited:
Upvote 0

NJDude

Expert
Licensed User
Longtime User
You just need the location of the downloaded file:
B4X:
TheFile = File.DirInternal & "/MyApk.apk"

iIntent.Initialize(iIntent.ACTION_VIEW, "file:///" & TheFile)

...

You download first, finished downloading, then install.
 
Last edited:
Upvote 0

Vinians2006

Active Member
Licensed User
Longtime User
Ok, I downloaded the file and verified that the file was there. But Im getting this BIG error see:
Oh my gosh..... Im sorry for a lot of question but I really need this. My app is done and I need this working.
Thanks a lot for trying to help me.
 
Upvote 0

Vinians2006

Active Member
Licensed User
Longtime User
Thanks a lot. Its seems that worked 50%, now Im getting this message "Há um problema com a anaslise do pacote" in english "There's a problem analising the package". Its because its a not signed apk ?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…