has Location Permission - Android Map

Android examples for Map:Location

Description

has Location Permission

Demo Code


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

public class Main {
    public static boolean hasLocationPermission(Context context) {
        return hasFineLocationPermission(context)
                || hasCoarseLocationPermission(context);
    }//  ww w  . ja v  a 2  s .co m

    public static boolean hasFineLocationPermission(Context context) {
        return context
                .checkCallingOrSelfPermission("android.permission.ACCESS_FINE_LOCATION") == 0;
    }

    public static boolean hasCoarseLocationPermission(Context context) {
        return context
                .checkCallingOrSelfPermission("android.permission.ACCESS_COARSE_LOCATION") == 0;
    }
}

Related Tutorials