Update app via download

Dman

Active Member
Licensed User
Longtime User
I have been working on downloading upgrades to my app using the info found here and I have it downloading and when I use the intent to try to install it, I get a Parse Error message stating that There was a problem parsing the package.

If I download it straight from the website it installs fine.

Here is my code. Am I missing something?

B4X:
 Sub upgrade
 
    upgradeari.Initialize("upgradeari", Me)
    upgradeari.Download("http://www.mysite.com/upgrade/myapp.apk")

End Sub
Sub JobDone (Job As HttpJob)

    Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
    If Job.Success = True Then
        Select Job.JobName
            Case "upgradeari"
                'print the result to the logs
                Log(Job.GetString)
            Dim i As Intent
               i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirInternalCache, "myapp.apk"))
               i.SetType("application/vnd.android.package-archive")
               StartActivity(i)
           End Select
    Else
        Log("Error: " & Job.ErrorMessage)
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release
   
End Sub
 

NJDude

Expert
Licensed User
Longtime User
Change the location of the download to File.DirDefaultExternal, File.DirInternalCache and File.DirInternal can be accessed only by your app, in your case it fails because the installer cannot access this location.
 
Upvote 0

Dman

Active Member
Licensed User
Longtime User
Not rightly sure how to do that since I didn't specify where to download it to. I assume it is handled by the httputils module?
 
Upvote 0

Dman

Active Member
Licensed User
Longtime User
OK I think I am getting close. I have successfully downloaded the file and copied it to File.DirDefaultExternal. Now I have a problem with an activitynotfound exception.

It says No activity found to handle intent. Is this code not correct?
B4X:
            Dim i As Intent
               i.Initialize(i.ACTION_VIEW, File.DirDefaultExternal & "/myapp.apk")
               i.SetType("application/vnd.android.package-archive")
               StartActivity(i)
 
Upvote 0

Dman

Active Member
Licensed User
Longtime User
Got it. After 8 hours.... :)

This worked:

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