actually I can't listen the hardware state.![]()
With ToggleLibrary, you can currently do the following:
- Bluetooth: Toggle, Enable, Disable, Check.
- Airplane Mode: Toggle, Enable, Disable, Check.
- WiFi: Toggle, Enable, Disable, Check.
- GPS: Toggle, Enable, Disable, Check.
- DataConnection** (GPRS,...): Toggle, Enable, Disable, Check.
So i believe you CAN check the state....
Just call the getters after you initialized the lib????how can I use from this library in service?
LogCat connected to: 05157df57d72d204
--------- beginning of main
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (mysvc) Create **
AirplaneMode=false
Bluetooth=false
DataConnection=false
GPS=false
RingerMode=2
isScreenOn=true
WIFI=true
** Service (mysvc) Start **
** Activity (main) Pause, UserClosed = false **
** Service (mysvc) Destroy **
Use a real device! The emulator is slow and unreliable.I use your app on emulator-5554
but your app only worked for First Run
and for second and more time don't work
I´ve started the app. Look at the log and quit the app. Start it again...** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (mysvc) Create **
AirplaneMode=false
Bluetooth=false
DataConnection=false
GPS=false
RingerMode=2
isScreenOn=true
WIFI=true
** Service (mysvc) Start **
** Activity (main) Pause, UserClosed = false **
** Service (mysvc) Destroy **
** Activity (main) Resume **
** Service (mysvc) Create **
AirplaneMode=false
Bluetooth=false
DataConnection=false
GPS=false
RingerMode=2
isScreenOn=true
WIFI=true
** Service (mysvc) Start **
** Activity (main) Pause, UserClosed = true **
** Service (mysvc) Destroy **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Service (mysvc) Create **
AirplaneMode=false
Bluetooth=false
DataConnection=false
GPS=false
RingerMode=2
isScreenOn=true
WIFI=true
** Service (mysvc) Start **
** Activity (main) Pause, UserClosed = true **
** Service (mysvc) Destroy **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Service (mysvc) Create **
AirplaneMode=false
Bluetooth=false
DataConnection=false
GPS=false
RingerMode=2
isScreenOn=true
WIFI=true
** Service (mysvc) Start **
** Activity (main) Pause, UserClosed = true **
** Service (mysvc) Destroy **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Service (mysvc) Create **
AirplaneMode=false
Bluetooth=false
DataConnection=false
GPS=false
RingerMode=2
isScreenOn=true
WIFI=true
** Service (mysvc) Start **
** Activity (main) Pause, UserClosed = true **
** Service (mysvc) Destroy **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Service (mysvc) Create **
AirplaneMode=false
Bluetooth=false
DataConnection=false
GPS=false
RingerMode=2
isScreenOn=true
WIFI=true
** Service (mysvc) Start **
** Activity (main) Pause, UserClosed = true **
** Service (mysvc) Destroy **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Service (mysvc) Create **
AirplaneMode=false
Bluetooth=false
DataConnection=false
GPS=false
RingerMode=2
isScreenOn=true
WIFI=true
** Service (mysvc) Start **
** Activity (main) Pause, UserClosed = true **
** Service (mysvc) Destroy **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Service (mysvc) Create **
AirplaneMode=false
Bluetooth=false
DataConnection=false
GPS=false
RingerMode=2
isScreenOn=true
WIFI=true
** Service (mysvc) Start **
** Activity (main) Pause, UserClosed = true **
** Service (mysvc) Destroy **
Use a real device! The emulator is slow and unreliable.
I´ve started the app. Look at the log and quit the app. Start it again...
Over and over. Everytime it works for me.
'example only, will not work
Sub Wifi_StateChange(State as Boolean)
If State = True Then
Log("Wifi was just turned on")
Else
Log("Wifi was just turned off")
End If
End Sub
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim Ringer As Int
Dim Toggle As Toggle
Dim T As Timer
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.
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")
If FirstTime = True Then
Toggle.Initialize
Ringer = Toggle.RingerMode
T.Initialize("timer",1000)
T.Enabled = True
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed = True Then T.Enabled = False
End Sub
Sub Timer_Tick
If Toggle.RingerMode <> Ringer Then
Ringer = Toggle.RingerMode
DoRingerChange(Ringer)
End If
End Sub
Sub DoRingerChange(R As Int)
Select R
Case Toggle.RINGER_MODE_NORMAL
Log("Ringer Mode Normal")
Case Toggle.RINGER_MODE_SILENT
Log("Ringer Mode Silent")
Case Toggle.RINGER_MODE_VIBRATE
Log("Ringer Mode Vibrate")
Case Else
Log("Unknown Mode")
End Select
End Sub