Android Question (SOLVED) Download and upgrade my App

Vinians2006

Active Member
Licensed User
Longtime User
Hi guys, I tryed a lot to find the solution for this problem but was unssucessfull.
I´m tring to let the users update my app clicking a button. When the user clicks the button, the app download the lastest apk and call an intent to call the installer. The download part works fine, but when I try to call the intent I get a error message.
Erro de Analise - Ocorreu um problema ao analisar o pacote
The user device is allowing installtions of unknow sources...
The code is :
B4X:
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
    ToastMessageShow("Donwload ok!", False)
   
    Dim i   As Intent
    Dim uri As String
    Dim PastaDisp as String
    PastaDisp = File.DirInternal 'here is where the apk is
    uri = "file://" & File.Combine(PastaDisp, "NSCommander.apk")
    i.Initialize(i.ACTION_VIEW, uri)
    i.SetType("application/vnd.android.package-archive")
   
    StartActivity(i)   
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
Insert 1 o 2 second of wait before StartActivity
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Sorry I did not see File.DirInternal is wrong. Must be File.DirRootExternal.
File.DirInternal is for exclusive use of your App, if you have to send it to other App or s.o. You have to use an external folder
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
B4X:
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
    Dim i As Intent
    Dim uri As String
    Dim PastaDisp As String

    ToastMessageShow("Donwload ok!", False)

    If File.Exist(File.DirRootExternal,"Temp")=False Then File.MakeDir(File.DirRootExternal,"Temp")
    File.Copy(File.DirInternal,PastaDisp ,File.DirRootExternal & "\Temp",PastaDisp)

    PastaDisp = File.DirRootExternal & "\Temp"
    uri = "file://" & File.Combine(PastaDisp, "NSCommander.apk")
    i.Initialize(i.ACTION_VIEW, uri)
    i.SetType("application/vnd.android.package-archive")
    StartActivity(i)
End Sub
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
What solution did you use?
 
Upvote 0

Vinians2006

Active Member
Licensed User
Longtime User
None of them, I discovered that download function was not working..., so I figured out the problem (a wrong folder name) and all worked fine.
 
Upvote 0
Top