How to enable/disable GPS toggle programmatically?

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

How to enable/disable GPS toggle programmatically?

Postby pranav09 » Mon Sep 06, 2010 11:54 am

Hi all,

I can enable GPS toggle programmetically using below code which will start an activity to enable/disable it.

if(!LocationManager.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER))
{
Intent i = new Intent( Settings.ACTION_SECURITY_SETTINGS ); startActivity(i);
....
}

So, now i want to enable/disable GPS without opening activity to enable/disable it. I don't want that user interpret with activity instead of it should be enable/disable directly. I am using Android 1.6 and 2.1. How is it possible to do?

Regards,
Pranav
User avatar
pranav09
Senior Developer
Senior Developer
 
Posts: 128
Joined: Mon Jan 19, 2009 12:01 pm
Location: Ahmedabad, India

Top

Re: How to enable/disable GPS toggle programmatically?

Postby vvxifeng16 » Tue Sep 07, 2010 3:06 am

Hello .. I have encountered such a problem .. tried many ways will not work .. .. trouble is I who teach the next
vvxifeng16
Freshman
Freshman
 
Posts: 8
Joined: Wed Jul 07, 2010 3:56 am

Re: How to enable/disable GPS toggle programmatically?

Postby pranav09 » Thu Sep 16, 2010 6:10 am

Hey! Any further help?
Pranav
User avatar
pranav09
Senior Developer
Senior Developer
 
Posts: 128
Joined: Mon Jan 19, 2009 12:01 pm
Location: Ahmedabad, India

Re: How to enable/disable GPS toggle programmatically?

Postby smbogdan » Sat Jun 11, 2011 3:58 pm

Hello, I need this too, I found that we can use it only with android versions 1.5 and lower, but I didn't find any code to do it... Anyone could help?
smbogdan
Junior Developer
Junior Developer
 
Posts: 24
Joined: Thu Mar 10, 2011 4:52 pm

Re: How to enable/disable GPS toggle programmatically?

Postby da3dalu5 » Mon Jun 13, 2011 11:44 am

I am having trouble understanding the problem from your post, could you give an example of each scenario? One you have and one you would like to have?
~D

“If you only do what you know you can do- you never do very much.”
da3dalu5
Junior Developer
Junior Developer
 
Posts: 13
Joined: Tue Apr 05, 2011 10:52 am

Re: How to enable/disable GPS toggle programmatically?

Postby da3dalu5 » Mon Jun 13, 2011 11:50 am

Just after I posted that I think I figured out what you are looking for:

locationManager.removeUpdates(locationListener);

That line of code basically stops your device looking for GPS updates, essentially turning it off.

I THINK that is want you are looking for anyway :P
~D

“If you only do what you know you can do- you never do very much.”
da3dalu5
Junior Developer
Junior Developer
 
Posts: 13
Joined: Tue Apr 05, 2011 10:52 am

Top

Return to Map Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests