0

Basically, in case GPS is turned on under text box to say 'Enabled' and if it is turned of, put text in text box that says 'Disabled'.

nebasjoa
  • 3
  • 4

3 Answers3

1
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
textbox_name.setText("Enable");
}
else
textbox_name.setText("Disabled");

Try this it will help you.

Rakshit Nawani
  • 2,490
  • 12
  • 25
0

It's nothing about Android development, it's basically simple thinking, but in Android it will look like (assuming you have the other parts):

textView.setText(isGpsTurnedOn ? "Enabled" : "Disabled");

If you're interested in getting the GPS status, then look at this question.

Community
  • 1
  • 1
Tamás Cseh
  • 2,890
  • 1
  • 17
  • 29
0

Please find this code i hope it will help you

PackageManager pm = getApplicationContext().getPackageManager();
boolean hasGps = pm.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS);
if(hasGps){
LocationManager locationManager = (LocationManager)getSystemService(LOCATION_SERVICE);
if(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){            
//set enable into TextView here         
}else{
//set Disable into TextView here 
}
}else{
//set Toast for GPS not available into your device
}
Hitesh Singh
  • 1,743
  • 1
  • 9
  • 15