Advertisement
Guest User

gpss

a guest
Jul 28th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
  2. && checkSelfPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION)
  3. != PackageManager.PERMISSION_GRANTED
  4. && checkSelfPermission(android.Manifest.permission.ACCESS_FINE_LOCATION)
  5. != PackageManager.PERMISSION_GRANTED) {
  6. requestPermissions(
  7. new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION,
  8. android.Manifest.permission.ACCESS_FINE_LOCATION},
  9. 100);
  10.  
  11.  
  12.  
  13. } else {
  14. try {
  15. //detect location based gps
  16. gps = new GPSTracker(MapsActivity.this);
  17. if (gps.canGetLocation()) {
  18. double latitude = gps.getLatitude();
  19. double longitude = gps.getLongitude();
  20. mMap.clear();
  21. LatLng posisi_user = new LatLng(latitude, longitude);
  22. mMap.addMarker(new MarkerOptions().position(posisi_user).
  23. title("posisi anda"));
  24. NurHelper.showSettingGps(MapsActivity.this);
  25.  
  26.  
  27. } else {
  28.  
  29.  
  30. }
  31. } catch (NullPointerException e) {
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement