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'.
Asked
Active
Viewed 55 times
3 Answers
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,604
- 14
- 27
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
- 3,050
- 1
- 20
- 30
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,951
- 1
- 10
- 15