Getting Location Info in Android


<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />



public static final int REQUEST_CODE = 123;
LocationManager mLocationManager; 
LocationListener mLocationListener;
protected void onResume(){
private void getCurrentLocation() {
    Log.d("Clima", "getWeatherForCurrentLocation");
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mLocationListener = new LocationListener() {
        public void onLocationChanged(Location location) {
            Log.d("Clima", "onLocationChanged");
            String longitude = String.valueOf(location.getLongitude());
            String latitude = String.valueOf(location.getLatitude());
            Log.d("Clima", "longitude is: " +longitude);
            Log.d("Clima","latitude is: " + latitude);

        public void onStatusChanged(String s, int i, Bundle bundle) {


        public void onProviderEnabled(String s) {


        public void onProviderDisabled(String s) {

    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
            && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_CODE);
    mLocationManager.requestLocationUpdates(LOCAION_PROVIDER, MIN_TIME, MIN_DISTANCE, mLocationListener);


public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    Log.d("Clima", "onRequestPermissionsResult");
    if (requestCode == REQUEST_CODE) {
        if(grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){

Passing data between AndroidActivities

Sending data

private void openVideoActivity(String video) {
    Intent newActivity = new Intent(this, PlayerActivity.class);
    newActivity.putExtra("videoId", video);

Retrieving data

final String videoID = getIntent().getExtras().getString("videoID");


Fiddling around with a Java project from my friend Thomas Berger I encountered lombok:

Lombok e.g. generates automagically setter and getter for data classes. all You have to do is annotate a class with @Data

import lombok.Data;

public class CinemaEvent {
    private String location;
    private String url;

For IntelliJ there is a lombok plugin. After activating the plugin the structure looks like this:

And there are many more convenience wrapper annotations! Try it out!

Maven Dependency


Add Vaadin Maven Archetype to IntelliJ

On Windows You can add the Maven archetype for Vaadin to IntelliJ IDEA the following way:



and add the line:

 <archetype groupId="com.vaadin" artifactId="vaadin-archetype-application" version="8.3.2" />

Now you can create a new Vaadin project via Maven