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 52 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.
![](../../users/profiles/4665938.webp)
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.
![](../../users/profiles/-1.webp)
Community
- 1
- 1
![](../../users/profiles/1237347.webp)
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
}
![](../../users/profiles/2248045.webp)
Hitesh Singh
- 1,743
- 1
- 9
- 15