Guest User

Untitled

a guest
Jul 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. public void onProviderEnabled(String provider);
  2. public void onProviderDisabled(String provider);
  3.  
  4. <action android:name="android.location.PROVIDERS_CHANGED" />
  5.  
  6. <receiver android:name=".gps.GpsLocationReceiver">
  7. <intent-filter>
  8. <action android:name="android.location.PROVIDERS_CHANGED" />
  9. <category android:name="android.intent.category.DEFAULT" />
  10. </intent-filter>
  11. </receiver>
  12.  
  13. public class GpsLocationReceiver extends BroadcastReceiver implements LocationListener
  14. ...
  15.  
  16. @Override
  17. public void onReceive(Context context, Intent intent)
  18. {
  19. if (intent.getAction().matches("android.location.PROVIDERS_CHANGED"))
  20. {
  21. // react on GPS provider change action
  22. }
  23. }
  24.  
  25. try {
  26. locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
  27.  
  28. if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
  29.  
  30. Log.i("About GPS", "GPS is Enabled in your devide");
  31. } else {
  32. //showAlert
  33. }
Add Comment
Please, Sign In to add comment