Android Question Android wifi bug?

0CrimsonScythe0

Member
Licensed User
Longtime User
My application uses the proximity sensor to turn wifi on or off based on its current state. There are radiobuttons to select what the app should do when the sensor is triggered. There are options of turning the screen on , toggling wifi and bluetooth.
The problem is that when I switch from toggling wifi , to turning on the screen and then back to toggling wifi , wifi doesn't turn off , it keeps on turning on again when the sensor is triggered. This problem does not occur in android 4.2.2 but it occurs in versions 2.3.5 and 4.0.4.
If I don't switch between the options and keep the radiobutton on the wifi label checked , the problem doesn't occur.
I am not sure how I can be helped on this issue but it is bothering me.
 

Attachments

  • Screenshot_2014-11-04-18-26-27.png
    Screenshot_2014-11-04-18-26-27.png
    36.4 KB · Views: 115

0CrimsonScythe0

Member
Licensed User
Longtime User
One more thing this only happens with wifi, not with bluetooth.
I am a beginner , so the code may not be as perfect as it can be but here it is:


B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
Dim vibrate As PhoneVibrate
Dim phonesensor As PhoneSensors
Dim notification1 As Notification
Dim toggle1 As Toggle




End Sub
Sub Service_Create
phonesensor.Initialize(phonesensor.TYPE_PROXIMITY)
notification1.Initialize
toggle1.Initialize()




End Sub

Sub Service_Start (StartingIntent As Intent)
notification1.OnGoingEvent = True
notification1.Sound = False
notification1.vibrate = False
notification1.Icon = "icon"
notification1.SetInfo("App is running" , "tap to stop app" , Main)
notification1.Notify(1)
phonesensor.StartListening("phonesensor")



End Sub

Sub phonesensor_SensorChanged (Values() As Float)
Service.StartForeground(1 , notification1)
If Values(0) = 0 Then
toggle1.ToggleWiFi
vibrate.vibrate(200)



End If

End Sub



Sub Service_Destroy

End Sub
 
Upvote 0
Top