get Location Sync Status - Android Map

Android examples for Map:Location

Description

get Location Sync Status

Demo Code


//package com.java2s;
import android.content.Context;

import android.location.LocationManager;

public class Main {
    public static int TYPE_GPS = 1;
    public static int TYPE_WIFI_NETWORK = 2;
    public static int TYPE_NOT_AVAILABLE = 0;

    public static int getLocationSyncStatus(Context context) {
        LocationManager manager = (LocationManager) context
                .getSystemService(Context.LOCATION_SERVICE);
        if (manager != null) {
            if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER))
                return TYPE_GPS;
            if (manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
                return TYPE_WIFI_NETWORK;
        }//  w  w  w .j a v a2 s . c o m
        return TYPE_NOT_AVAILABLE;
    }
}

Related Tutorials