Manifest
AddPermission(android.permission.WRITE_SECURE_SETTINGS)
Sub SetAirplaneMode(On As Boolean)
Dim p As Phone
Dim r As Reflector
Dim contentResolver As Object
r.Target = r.GetContext
contentResolver = r.RunMethod("getContentResolver")
Dim state As Int
' // turn off
If Not(On) Then
state = 0
Else
' // turn on
state = 1
End If
r.RunStaticMethod("android.provider.Settings$Global", "putInt", _
Array As Object(contentResolver, "airplane_mode_on", state), _
Array As String("android.content.ContentResolver", "java.lang.String", "java.lang.int"))
Try
Dim i As Intent
i.Initialize("android.intent.action.AIRPLANE_MODE", "")
i.PutExtra("state", On)
p.SendBroadcastIntent(i)
Catch
log($"mod_functions::SetAirplaneMode(${On}) - error ${LastException.Message}"$)
End Try
End Sub