Update app problem

GaNdAlF89

Active Member
Licensed User
Longtime User
I update my app downloading the new apk from a personal server, not from Google Play, but during the update setup android asks me a confirmation to replace the existing app with the new version. There is any way to skip this step? I would like something as Google Play Store, which automatically runs the updates without user interaction. Thanks!
 

GaNdAlF89

Active Member
Licensed User
Longtime User
Ok, therefore can I to capture the Cancel button (like cancel button of MsgBox2) pressed when Android ask confirmation to replace the existing app? For example, Android ask to replace the existing app, but the user press on Cancel...
 
Upvote 0

GaNdAlF89

Active Member
Licensed User
Longtime User
I post the code in which I have this problem. This is something like a launcher, that checks if there is a new apk (downloaded from the main app), and if true it installs this and then starts app. If false, it just starts app.

B4X:
If File.Exists(File.DirRootExternal,"dir/dir/..../setup.apk") Then

    'if there is a new apk, installs it
            
    Dim iIntent As Intent 
    iIntent.Initialize(iIntent.ACTION_VIEW,"file:///sdcard/dir/dir/..../setup.apk")
    iIntent.SetType("application/vnd.android.package-archive")

    StartActivity(iIntent) 
    
    'I have to wait for user click on the setup confirmation - There are other solutions??
    Sleep(SetupInterval * DateTime.TicksPerSecond)
            
    Dim in As Intent
    in.Initialize(in.ACTION_MAIN, "")
    in.SetComponent("package_name")
    
    'Problem
    'if user clicks on Cancel, and then clicks on Android Settings button (in tray), this row is executed but it doesn't work!!   
    StartActivity(in)
            
Else 
    'if there isn't an update, it starts the app

    Dim in As Intent
    in.Initialize(in.ACTION_MAIN, "")
    in.SetComponent("package_name")
            
    StartActivity(in)
            
End If

Sleep function:
B4X:
Sub Sleep(ticks As Int)

    DoEvents
   
    If ticks > 0 AND DateTime.TicksPerSecond > 0 Then
        Dim milliseconds As Int: milliseconds = 1000 / DateTime.TicksPerSecond * ticks
        Dim Lock1 As Lock
      
        Lock1.Initialize(True)
        Lock1.WaitFor(milliseconds)
        Lock1.Unlock
      
    End If
   
End Sub
 
Last edited:
Upvote 0
Top