TurnGPS Library

XverhelstX

Well-Known Member
Licensed User
Longtime User
With this library, you can toggle the GPS remotely.

HOW TO:

B4X:
Sub btnTurn_Click

Dim turnOn As TurnGPS

turnOn.Initialize()
turnOn.turnGPS()

End Sub

I'll add later the ability to enable/disable the GPS remotely instead off toggling. [FIXED!, see post below]

A lot of help goes to Agraham and Erel.

Thanks!

XverhelstX
 

Attachments

  • TurnGPS.zip
    2.9 KB · Views: 2,300
Last edited:

XverhelstX

Well-Known Member
Licensed User
Longtime User
First post has been update.

Now you can use TurnGPSOn() or TurnGPSOff() to toggle the GPS.

B4X:
Sub Activity_Create(FirstTime As Boolean)

activity.LoadLayout("Layout")




End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub btnStart_Click

turnOn.Initialize()
turnOn.turnGPSOn


End Sub

Sub btnStop_Click

turnOn.Initialize()
turnOn.turnGPSOff()

End Sub

XverhelstX
 

gorelshv

Member
Licensed User
Longtime User
This should be added to the gps library. Also, I understand that this is based on bug that could be fixed in future versions of android.
 

dlfallen

Active Member
Licensed User
Longtime User
Thanks for sharing this. It works flawlessly on my Moterola Droid2. I find it quite useful in the program I am developing (GPSlog). Of course, I will make it's use optional when I release the program. For me, on my device, it is lovely!
 

XverhelstX

Well-Known Member
Licensed User
Longtime User
This should be added to the gps library. Also, I understand that this is based on bug that could be fixed in future versions of android.

I won't add it to the GPS library cause I will add a bunch more on/off switches.

Yep, it's based on an exploit bug, but I'm not sure if they going to fix it.
All it does is send a intent to the gps widget.

Can You make This for Bluetooth also ?

regards
Albert

I'm currently trying to add it to the Turn Library.
I'm just having problems with the startactvity feature.

Thank you for sharing this library

If you can please send a private message to Cableguy and he will add it to the list of libraries that he maintains.

Thanks! I will message him later today.

Thanks for sharing this. It works flawlessly on my Moterola Droid2. I find it quite useful in the program I am developing (GPSlog). Of course, I will make it's use optional when I release the program. For me, on my device, it is lovely!

Glad to hear!

Works fine on my Xperia X10 and Play to

Thanks!
 

molder26

Member
Licensed User
Longtime User
Hi guys, someone tested it on android 1.5?
Because i checked it and doesn't work for me in 1.5, maybe this bug is for 1.6 and above.
Regards
 

dlfallen

Active Member
Licensed User
Longtime User
I have an Acer A500 10inch tablet, recently upgraded from Android 3.0 to 3.1. It works fine with both Android versions.
 

Rusty

Well-Known Member
Licensed User
Longtime User
TurnGPS

Works well on my Samsung Charge.
It would be nice if you could determine if the GPS unit is on or off so you could restore the state of the unit upon exit of your program. i.e. if it is off when you begin your program you can turn it on and the when you are through, turn it back off, or leave it on depending the state at the beginning. Nice Lib.
 

agraham

Expert
Licensed User
Longtime User
If by "on or off" you mean whether the user has enabled "Use GPS Satellites" in Settings then you can do it with this Reflection library fragment.

B4X:
   Dim Obj1 As Reflector, GPSon As Boolean
   Dim gps1 As GPS ' needed for ACCESS_FINE_LOCATION permission
   Obj1.Target = Obj1.GetContext
   Obj1.Target = Obj1.RunMethod2("getSystemService", "location", "java.lang.String")
   GPSon = Obj1.RunMethod2("isProviderEnabled", "gps", "java.lang.String")
   Msgbox(GPSon, "GPS enabled?")
 

Shay

Well-Known Member
Licensed User
Longtime User
Android 2.3

Hi

So there isn't any way to turn on/off the GPS by software command
(automatically without user intervention) with Andriod 2.3.x?

Shay
 
Top