Novice Question:
Can someone help me with this , how do I set Button & Menu Text to ( Toggle button Graphic)
"ON / OFF" for items like GPS Flight Mode Bluetooth etc ?
Can someone help me with this , how do I set Button & Menu Text to ( Toggle button Graphic)
"ON / OFF" for items like GPS Flight Mode Bluetooth etc ?
B4X:
'SetAirplaneMode()
SetAirplaneMode(False)
Sub SetAirplaneMode(On As Boolean)
Dim p As Phone
If on = GetAirplaneMode Then Return 'already in the correct state
Dim r As Reflector
Dim contentResolver As Object
r.Target = r.GetContext
contentResolver = r.RunMethod("getContentResolver")
Dim state As Int
If on Then state = 1 Else state = 0
r.RunStaticMethod("android.provider.Settings$System", "putInt", _
Array As Object(contentResolver, "airplane_mode_on", state), _
Array As String("android.content.ContentResolver", "java.lang.String", "java.lang.int"))
Dim i As Intent
i.Initialize("android.intent.action.AIRPLANE_MODE", "")
i.PutExtra("state", "" & On)
p.SendBroadcastIntent(i)
End Sub
Sub GetAirplaneMode As Boolean
Dim p As Phone
Return p.GetSettings("airplane_mode_on") = 1
End Sub
Sub btnAirPlaneMode_Click
SetAirplaneMode(Not(GetAirplaneMode))
Log(GetAirplaneMode)
Dim i As Int
Dim but As Button
but = Sender
i=but.text
i=i-1
If buttonstate(i)=False Then
but.Text="ON"
Else
but.Text="OFF"
End If
End Sub
Last edited: