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

Blogreader error

What does this error mean?

boolean com.example.blogreader2.MainListActivity.isNetworkAvailable()

5 Answers

You are missing all of the other information provided to you with it. If thats a line out of your logcat, please post the entire thing.

All you posted is a package name, class name, and a method. Within the context of what you provided, it means nothing.

How would I post everything on here that is needed?

Right click, then copy and paste?

Maybe we are not on the same page yet.

Where does "boolean com.example.blogreader2.MainListActivity.isNetworkAvailable()" come from, what are you doing when you see it. What part of the IDE are you looking at, when you see it?

On the far right of my IDE next to isNetworkAvailable() also when I hover over it I see that error.

package com.example.blogreader;

import java.io.IOException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL;

import android.app.ListActivity; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.widget.Toast;

public class MainListActivity extends ListActivity {

protected String [] mBlogPostsTitles;
public static final int NUMBER_OF_POSTS = 20;
public static final String TAG = MainListActivity.class.getSimpleName();



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_list);

    if(isNetworkAvailable()){

    GetBlogPostsTask getBlogPostsTask = new GetBlogPostsTask();
    getBlogPostsTask.execute();
    }

    else{
        Toast.makeText(this, "The network is currently 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;
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main_list, menu);
    return true;
}


private class GetBlogPostsTask extends AsyncTask<Object, Void, String>
    {

    @Override
    protected String doInBackground(Object... params) 
        {
            int responseCode = -1; 
            try
            {
            URL blogFeedUrl = new URL("http://blog.teamtreehouse.com/api/get_recent_summary/?count=" + NUMBER_OF_POSTS);
            HttpURLConnection connection = (HttpURLConnection) blogFeedUrl.openConnection();
            connection.connect(); 

            responseCode = connection.getResponseCode();
            Log.i(TAG, "Code: " + responseCode);
            }
        catch(MalformedURLException e)
            {
                Log.e(TAG, "Exception Found: ", e);
            }
        catch(IOException e)
            {
                Log.e(TAG, "Exception Found: " ,e);
            }
        catch(Exception e)
        {
            Log.e(TAG, "Exception Found: ", e);
        }
            return "Code: " +responseCode;
        }

    }

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

}

What are you hovering over when you see that?