Android Question Shutdown menu

Declan

Well-Known Member
Licensed User
Is it possible to call the OS "Shutdown/Reboot/Airplane" menu display from within an app.
I would like to display this when the user clicks the "Exit" button of my app.
 

wes58

Active Member
Licensed User
Actually, if you have a rooted phone you can do it like this:
Shutdown the phone:
B4X:
Sub Shutdown
    Dim ph As Phone
    Dim Command, Runner As String
    Dim StdOut, StdErr As StringBuilder

    StdOut.Initialize
    StdErr.Initialize
    Runner = File.Combine(File.DirInternalCache, "runner")
    Command = File.Combine(File.DirInternalCache, "command")
    File.WriteString(File.DirInternalCache, "runner", "su < " & Command)
     File.WriteString(File.DirInternalCache, "command", "su -c reboot -p")  
    ph.Shell("sh", Array As String(Runner), StdOut, StdErr)   
End Sub
Reboot the phone:
B4X:
Sub Reboot
    Dim ph As Phone
    Dim Command, Runner As String
    Dim StdOut, StdErr As StringBuilder

    StdOut.Initialize
    StdErr.Initialize
    Runner = File.Combine(File.DirInternalCache, "runner")
    Command = File.Combine(File.DirInternalCache, "command")
    File.WriteString(File.DirInternalCache, "runner", "su < " & Command)
    File.WriteString(File.DirInternalCache, "command", "su -c reboot")
    ph.Shell("sh", Array As String(Runner), StdOut, StdErr)   
End Sub
It may not work on Android 6. Tested on 5.1.1
 
Upvote 0
Top