Guest User

Untitled

a guest
Feb 18th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1.     double latitude;
  2.     double longitude;
  3.  
  4.     public void getLocation() {
  5.         LocationManager mlocManager=null;
  6.         LocationListener mlocListener;
  7.         mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
  8.         mlocListener = new MyLocationListener();
  9.        mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
  10.  
  11.        if (mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
  12.            if(MyLocationListener.latitude>0)
  13.            {
  14.                latitude = MyLocationListener.latitude;
  15.                longitude = MyLocationListener.longitude;
  16.                makeMap();
  17.             }
  18.             else
  19.             {
  20.                  alert.setTitle("Wait");
  21.                  alert.setMessage("GPS in progress, please wait.");
  22.                  alert.setPositiveButton("OK", null);
  23.                  alert.show();
  24.              }
  25.          }
  26.     }
Add Comment
Please, Sign In to add comment