Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Blog Reader Android App Getting Data from the Web What To Do When the Network is Down

Carney Bernard
Carney Bernard
3,615 Points

BlogReader App Not Working

I am following along with the video yet I am still having problems. I looked in the logcat and it says: Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10054 nor current process has android.permission.ACCESS_NETWORK_STATE.

I tried to add the access network state manually and it does not look like it worked. In the video Ben uses Eclipse to get permission to access the network, but on Android Studio you have to do so manually. Here is a snippet of my code for the AndroidManifest.xml class:

<uses-permission android:name="android.permission.INTERNET" android:permission="android.permission.ACCESS_NETWORK_STATE"/>

Also the logcat says there are errors on line 34 and 45 of the MyListActivity Class. All from which are steps added this video:

if (isNetworkAvailable()) { GetBlogPostTask getBlogPostTask = new GetBlogPostTask(); getBlogPostTask.execute(); } else { Toast.makeText(this, "Network is unavailable.", Toast.LENGTH_LONG).show(); } }

private boolean isNetworkAvailable() {
    ConnectivityManager manager = (ConnectivityManager)
            getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = manager.getActiveNetworkInfo();

    boolean isAvailable = false;
    if(networkInfo != null && networkInfo.isConnected()){
       isAvailable = true;
    }

     return isAvailable;

}

If anyone could please help me figure this out that would be much appreciated!