DaveDave
DaveDave

Reputation: 303

Android: Location based app

I am just beginner on Android app developing. I have a few question. I am looking to create a location based simple reminder app. There are a lot tutorials but I am looking for a specific feature where a user creates reminder and it obtains current location and once it is created it is placed on the map (I dont know what type of object this would be, will it be a marker by calling the API) with its own unique geo-fence where the user can see it.

A user can make multiple reminders as it is saved in a database. I have currently implemented a simple GUI with Google maps by following a tutorial with a log in system so each reminder created will be unique to the user

Upvotes: 1

Views: 660

Answers (2)

jlmd
jlmd

Reputation: 161

When the user wants to create a reminder, you have to obtain his current location and place a marker in Google Maps with that location:

private LocationListener locationListener;
private LocationManager locationManager;
private Criteria criteria;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    initCriteria();
    initLocationListener();
}

private void initCriteria() {
    criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    criteria.setPowerRequirement(Criteria.POWER_HIGH);
}

private void initLocationListener() {
    locationListener = new LocationListener() {

        @Override
        public void onLocationChanged(Location location) {
            placeMapMarkerInLocation(location);
        }

        @Override
        public void onProviderDisabled(String provider) {
            // Empty

        }

        @Override
        public void onProviderEnabled(String provider) {
            // Empty
        }

        @Override
        public void onStatusChanged(String provider, int status,
                Bundle extras) {
            // Empty
        }
    };
}

// User create reminder action
private void createReminder() {
    locationManager.requestSingleUpdate(criteria, locationListener, null);
}

private void placeMapMarkerInLocation(Location location) {
    map.addMarker(new MarkerOptions()
        .position(new LatLng(location.getLatitude(), location.getLongitude()))
        .title("Im here!"));
}

Upvotes: 1

Igor
Igor

Reputation: 13

I cant get exactly what is your real question. But if its about how you'll get the remind markers into User's Google Map I think this link will point you in a good way: http://tips4php.net/2010/10/use-php-mysql-and-google-map-api-v3-for-displaying-data-on-map/. And if you are using App Inventor I suggest you to follow this tutorial doing a few tweaks: http://appinventor.mit.edu/explore/ai2/android-wheres-my-car.html

Upvotes: 0

Related Questions