Check if app has Access Network State Permission - Android Network

Android examples for Network:Network Operation

Description

Check if app has Access Network State Permission

Demo Code


//package com.java2s;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;

public class Main {
    public static boolean hasAccessNetworkStatePermission(Context context) {
        PackageManager packageManager = context.getPackageManager();
        return (packageManager.checkPermission(
                Manifest.permission.ACCESS_NETWORK_STATE,
                context.getPackageName()) == PackageManager.PERMISSION_GRANTED);
    }//  ww w . ja v  a 2  s. co m
}

Related Tutorials