Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainActivity extends AppCompatActivity {
- private static final String TAG = "MainActivity";
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- checkLocationPermission();
- Log.d(TAG, "Permission has been checked!");
- Position position = new Position(this);
- Log.d(TAG, "Latitude: ");
- String lat = position.getLatitude();
- Log.d(TAG, lat); // zwraca java.lang.NullPointerException: println needs a message
- }
- private void checkLocationPermission() {
- if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
- openGetLocationPermission();
- }
- private void openGetLocationPermission() {
- Intent intent = new Intent(this, GetLocationPermission.class);
- startActivity(intent);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement