Is ACCESS_NETWORK_STATE required to check user data connection

时间:2018-09-18 19:44:58

标签: android permissions connection

I was following this tutorial to check if the user has data connection (any type).

ConnectivityManager cm =
        (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);

NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null &&
                      activeNetwork.isConnectedOrConnecting();

I was wondering if the permission android.permission.ACCESS_NETWORK_STATE is required as it seems to work without, and there is no mention of it in the tuto?

0 个答案:

没有答案