Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

import android.location.LocationManager;

public class Main {
    /**
     * Tells whether location is enabled.
     *
     * @param context a reference to the context.
     * @return true if location is enabled, false otherwise.
     */
    public static boolean isLocationEnabled(Context context) {
        LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        boolean isGpsEnabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
        return isGpsEnabled | lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
    }
}