Running from New Install

Smee

Well-Known Member
Licensed User
Longtime User
I have used the following code to install a new version of a program after downloading it from the internet

Code: Copy
Sub InstallNewApk
   'ask the system to install the apk
   SQL.Close
   Dim i As Intent
   i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirRootExternal, "Waratah.apk"))
   i.SetType("application/vnd.android.package-archive")
   StartActivity(i)
   ExitApplication
End Sub

I took the code from Erel's Bridge Source code.

Everything works ok, to a point. When i press the button to "Start Now' nothing happens. I can manually run the new version ok but i want a user to just run straight from the install.

Can anyone see what i am missing?

TIA

Joe

update:

I was just looking at the code and i had originally assumed that i had to exit the installing app. I suppose thinking about it now it is actually terminating the newly installed app. Is this correct?
 
Last edited:
Programmatically installing App gives error

:sign0144:
I am getting the following error. The original statement using i.SetType also gave the same error (of course, the intent action was different).

An error has occured in sub:main_installnewapk(javaline: 250) android.content.ActivityNotFoundException: No Activity found to handle intent { act=android.intent.action.INSTALL_PACKAGE dat=/mnt/sdcard/MyAPKs/MyApp.apk flg=0x200000 }

StartActivity(i) statement is highlighted

Code: Copy
Sub InstallNewApk
    'ask the system to install the apk
    Dim i As Intent
    i.Initialize("android.intent.action.INSTALL_PACKAGE", File.DirRootExternal & "/MyAPKs/MyApp.apk")
'    i.SetType("application/vnd.android.package-archive")
   ToastMessageShow("Starting Install",False)
    StartActivity(i)
End Sub

Do I need to use the bridge library/any other library?

TIA
 
Upvote 0
Thanks! Problem solved

:signOops:I don't know what caused the error in the first place. I'm too new to fidget with code, unless I get an error.

I used the original code again (as you suggested) and changed the the path/apk name for my app and now it worked fine.

I had done the same thing earlier and I don't know where i went wrong.

:sign0013:I hope newbies are forgiven.

Thanks a lot for the prompt reply!
 
Last edited:
Upvote 0
Why would you install an app programmatically? What is the benefit as opposed to clicking the apk file and install? Does it save steps?
 
Upvote 0
Hi Arun / Team

I am able to install my updated app automatically . but I want my app to be opened again automatically once installed ..
How Can i open newly replaced app .. any idea or suggestion .
 
Upvote 0
Back
Top