Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

import android.location.LocationManager;
import android.util.Log;

public class Main {
    public static boolean isGpsOn(Context context) {
        boolean result = false;

        final LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

        try {
            if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                result = true;
            }
        } catch (IllegalArgumentException e) {
            Log.d("GPS Helper", "Looks like we do not have gps on the device");
        }

        return result;
    }
}