Returns whether the Location Service is available on the current device - Android Map

Android examples for Map:Location

Description

Returns whether the Location Service is available on the current device

Demo Code


//package com.java2s;

import android.content.Context;

public class Main {
    /**/*from w  ww  .j  a  v  a2 s .  co  m*/
     * Returns whether the Location Service is available on the current device
     *
     * @param ctx the current context
     * @return <code>true</code> if device supports location services <code>false
     * otherwise</code>
     */
    public static boolean isLocationAvailable(Context ctx) {
        Object service = ctx.getSystemService(Context.LOCATION_SERVICE);
        return (service != null);
    }
}

Related Tutorials