Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public void startGPS(View view)
  2. {
  3.  
  4. // Here is the code to handle permissions - you should not need to edit this.
  5. if ( Build.VERSION.SDK_INT >= 23 &&
  6. ContextCompat.checkSelfPermission( this, android.Manifest.permission.ACCESS_FINE_LOCATION ) != PackageManager.PERMISSION_GRANTED &&
  7. ContextCompat.checkSelfPermission( this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
  8. ActivityCompat.requestPermissions(this, new String[] { android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION }, TAKE_PHOTO_PERMISSION);
  9. }
  10.  
  11. locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  12. Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
  13. onLocationChanged(location);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement