Android Question Off/on data connection

bgsoft

Well-Known Member
Licensed User
In Android 5x it's posible, turn off/on data connection?

thanks
 

wes58

Active Member
Licensed User
In Android 5x it's posible, turn off/on data connection?

thanks
If you have a rooted phone you can use something like this:
B4X:
Sub ToggleDataConnection(dataState as Boolean)
    Dim ph As Phone
    Dim Command, Runner As String
    Dim StdOut, StdErr As StringBuilder
    Dim Result As Int
   
    StdOut.Initialize
    StdErr.Initialize
    Runner = File.Combine(File.DirInternalCache, "runner")
    Command = File.Combine(File.DirInternalCache, "command")
    File.WriteString(File.DirInternalCache, "runner", "su < " & Command)

    if dataState then         ' turn data connection on
        File.WriteString(File.DirInternalCache, "command", "svc data enable")
    else            ' turn data connection off
        File.WriteString(File.DirInternalCache, "command", "svc data disable")
    end if
    Result = ph.Shell("sh", Array As String(Runner), StdOut, StdErr)
End Sub
 

bgsoft

Well-Known Member
Licensed User
hi

Thank you for your contribution.

The problem is that most people who use this application are not root.

If Google continues its policy so restrict things, in the end, we can not to program anything

regards
 
Top