Returns if the device is location aware at this moment - Android Map

Android examples for Map:Location

Description

Returns if the device is location aware at this moment

Demo Code


//package com.java2s;
import java.util.List;
import android.content.Context;

import android.location.LocationManager;

public class Main {
    /**//from   w w w.j av a2  s  .  co  m
     * Returns if the device is location aware at this moment
     * 
     * @param context
     * @return
     */
    public static boolean isDeviceLocationAware(Context context,
            LocationManager locationManager) {

        List<String> providers = locationManager.getAllProviders();
        for (String provider : providers)
            if (locationManager.isProviderEnabled(provider))
                return true;

        return false;
    }
}

Related Tutorials