Android Question Apk Updates How to Start after updating?

ronovar

Active Member
Licensed User
Longtime User
I have the following code that works excellent:

B4X:
'DEFINE - Intent
                Dim iIntent As Intent
               
                'INITIALIZE - Intent
                iIntent.Initialize(iIntent.ACTION_VIEW, "file://" &File.DirRootExternal&"/Download/MyAPK.apk")
               
                'SET - Type
                iIntent.SetType("application/vnd.android.package-archive")
               
                'START - iIntent
                StartActivity(iIntent)

It runs installation, i press Install Button, all install fine...but i need to manually click on MyAPK.apk to start apk again after update.

So my question is:

How can i run automatically MyAPK.apk after installing update?
 

DonManfred

Expert
Licensed User
Longtime User
How can i run automatically MyAPK.apk after installing update?
If it is you app you can send an intent to start the app.

See Packagemanager and get the "starting-intent" for your app. Create a intent and start the intent then

But somewhere in my brain someone is talking that the user must explicitely start your app once
 
Upvote 0

ronovar

Active Member
Licensed User
Longtime User
this code is what you taking about?

B4X:
'SET - Type iIntent.SetType("application/vnd.android.package-archive")
 'START - iIntentStartActivity(iIntent)

This Create a itent and start the intent

So if i understand correctly...when apk is downloaded, and run using StartActivity(iIntent), user install apk and apk exits...so user needs manually to start apk again.
 
Upvote 0

ronovar

Active Member
Licensed User
Longtime User
Yes apk updates itself...so i have done this using httputils service:

- Download APK from Server
- Run APK after Downloaded
- User press button Install
- APK updates and user click on Finish button
- then user need manually to click to apk icon to start APK

So as i understand it is not possible to start my apk after autoupdate
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You can use a second app which does the work.

App A wants to update and downloads the apk
App A starts App B which then will call the intent to install the new apk.
App B waits till the new app is installed an then it will start your App A again.

My 2 Cent which is pure theory. Don´t know if this will work.
 
Upvote 0

Abraham

Member
Licensed User
Longtime User
Hello, mi name is Abraham, and
I've read the topic of downloading the .apk file with attention but I'm not knowledgeable enough with B4A to do it myself.
I like to do the same, I want to download an .apk from my website to my smartphone and then install the apk. Pls, can you help me
to do this in B4A?

Abraham
 
Upvote 0

ronovar

Active Member
Licensed User
Longtime User
Sorry..i was too late view this question....you need to use Download2Service to download file to download directory or tmp directory in your phone and then use intent tu run apk installer in B4A Code...it is simple...just search Downlaod2Service and intent install apk in this excellent forum there you find code examples.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
You could have a look at my lib AppUpdating using it "as is" or getting inspired by its code to develop your own solution.

udg
 
Upvote 0
Top