Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. <uses-permission android:name="android.permission.INTERNET" />
  2. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  3. <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  4.  
  5. <application
  6. android:allowBackup="true"
  7. android:icon="@mipmap/ic_launcher"
  8. android:label="@string/app_name"
  9. android:roundIcon="@mipmap/ic_launcher_round"
  10. android:supportsRtl="true"
  11. android:theme="@style/AppTheme">
  12. <activity android:name=".MainActivity">
  13. <intent-filter>
  14. <action android:name="android.intent.action.MAIN" />
  15.  
  16. <category android:name="android.intent.category.LAUNCHER" />
  17. </intent-filter>
  18. </activity>
  19. </application>
  20.  
  21. LocationManager lm =
  22. (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  23.  
  24. LocationListener listener = new LocationListener() {
  25. @Override
  26. public void onLocationChanged(Location location) {
  27. if (location!=null) {
  28. }
  29. else{
  30. }
  31. }
  32. @Override
  33. public void onStatusChanged(String provider, int status, Bundle extras) {
  34. }
  35. @Override
  36. public void onProviderEnabled(String provider) {
  37. }
  38. @Override
  39. public void onProviderDisabled(String provider) {
  40. }
  41. };
  42.  
  43.  
  44.  
  45.  
  46. if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED /*&& ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED*/) {
  47. // TODO: Consider calling
  48. // ActivityCompat#requestPermissions
  49. // here to request the missing permissions, and then overriding
  50. // public void onRequestPermissionsResult(int requestCode, String[] permissions,
  51. // int[] grantResults)
  52. // to handle the case where the user grants the permission. See the documentation
  53. // for ActivityCompat#requestPermissions for more details.
  54.  
  55. Log.e(TAG,"Error!");
  56. return;
  57. }
  58. lm.requestSingleUpdate(LocationManager.GPS_PROVIDER,listener,null);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement