Requests updates for the provided listener in the LocationManager , asking for updates from specific providers . - Android Map

Android examples for Map:Location Provider

Description

Requests updates for the provided listener in the LocationManager , asking for updates from specific providers .

Demo Code


//package com.java2s;
import android.content.Context;
import android.location.LocationListener;
import android.location.LocationManager;

public class Main {
    /**//from w  ww.  j  a v  a 2 s  . com
     * Requests updates for the provided {@code listener} in the {@link LocationManager}, asking for updates from
     * specific {@code providers}.
     */
    public static void register(Context context, LocationListener listener,
            String[] providers) {
        final LocationManager locationManager = (LocationManager) context
                .getSystemService(Context.LOCATION_SERVICE);

        for (String provider : providers) {
            locationManager.requestLocationUpdates(
                    LocationManager.GPS_PROVIDER, 0, 0, listener);
        }
    }
}

Related Tutorials