this demo is show you how to install an apk in silent method (need root),and you can use it the execute other command
demo code
b4aRootCmd
Author: IceFairy333
Version: 1
demo code
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim rc As RootCmd
Dim btninstall As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
btninstall.Initialize("btn")
btninstall.Text="Install Apk"
Activity.AddView(btninstall,0,0,-2,-2)
End Sub
Sub btn_Click
If rc.haveRoot Then
File.Copy(File.DirAssets,"testapk.apk",File.DirRootExternal,"testapk.apk") 'copy to sdcard because the assets dir is readable only this application
If rc.InstallApk(File.DirRootExternal&"/testapk.apk") Then
Msgbox("install ok","success")
Else
Msgbox("install error","error")
End If
Else
Msgbox("there is no root!","need Root")
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Author: IceFairy333
Version: 1
- RootCmd
Methods:- InstallApk (apkAbsolutePath As String) As Boolean
install apk in silent mode(need root) - execRootCmd (cmd As String) As String
- execRootCmdSilent (cmd As String) As Int
- haveRoot As Boolean
- InstallApk (apkAbsolutePath As String) As Boolean
Attachments
Last edited: