Is it possible to use http service to replace the apk of a currently running application? Will ultimately have approx 20 devices at same location running the app, and would like to simplify updating the app to all devices.
Dim Intent1 As Intent
Intent1.Initialize(Intent1.ACTION_VIEW, "file:///sdcard/temp.apk")
Intent1.SetType("application/vnd.android.package-archive")
StartActivity(Intent1)
I use defaultexternal but I think it's a matter of choiceSorry to appear so clueless, but: when I download the new APK, where should I save it to -- defaultexternal, defaultinternal, etc.
B4X:Intent1.SetType("application/vnd.android.package-archive")
Intent1.SetComponent("android/com.android.internal.app.ResolverActivity")
That's works perfect to install the update, but what about re-start the app after the installation?
Thanks
AddReceiverText(service1,
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>)
Hello MartinI'm pretty sure that you can only install an APK file that is saved to the device external memory.
Here's some code i used to update the currently running app:
B4X:Dim Intent1 As Intent Intent1.Initialize(Intent1.ACTION_VIEW, "file:///sdcard/temp.apk") Intent1.SetType("application/vnd.android.package-archive") StartActivity(Intent1)
The user will be prompted to give permission to install the APK - i don't think there's anyway to install an APK without the user being asked permission.
Martin.
Whai I need actually is the code that will launch the already existed APK and the process will not be interrupted to get user permission. It is possible only for rooted devices and I need the code like that:Hi all,
maybe the following link could be useful : AppUpdating library
Be sure to use version 1.25 which comes complete of example and source code.
Umberto
Sub btnAPK_Click
Dim Command, Runner As String
Dim StdOut, StdErr As StringBuilder
Dim Result As Int
Dim Ph As Phone
Dim MyPath as string = File.DirRootExternal & "/B4A"
Runner = File.Combine(File.DirInternalCache, "runner")
Command = File.Combine(File.DirInternalCache, "command")
File.WriteString(File.DirInternalCache, "runner", "su < " & Command)
File.WriteString(File.DirInternalCache, "command", "pm install -r "& File.Combine(MyPath, "Your.apk") & CRLF & _
"am start -n " & "b4a.your/b4a.your.main" & CRLF & "Exit") 'Any commands via crlf, and exit at end
StdOut.Initialize
StdErr.Initialize
Result = Ph.Shell("sh", Array As String(Runner), StdOut, StdErr)
Msgbox(StdOut.tostring, "")
End Sub
Hi
I think I have found a way to automatically update the APK without user confirmations and automatically restart it(for rooted devices)
B4X:Sub btnAPK_Click Dim Command, Runner As String Dim StdOut, StdErr As StringBuilder Dim Result As Int Dim Ph As Phone Dim MyPath as string = File.DirRootExternal & "/B4A" Runner = File.Combine(File.DirInternalCache, "runner") Command = File.Combine(File.DirInternalCache, "command") File.WriteString(File.DirInternalCache, "runner", "su < " & Command) File.WriteString(File.DirInternalCache, "command", "pm install -r "& File.Combine(MyPath, "Your.apk") & CRLF & _ "am start -n " & "b4a.your/b4a.your.main" & CRLF & "Exit") 'Any commands via crlf, and exit at end StdOut.Initialize StdErr.Initialize Result = Ph.Shell("sh", Array As String(Runner), StdOut, StdErr) Msgbox(StdOut.tostring, "") End Sub
"Your" is a name of your APK