if condition executing both blocks in debugger
<p>This is probably something stupid, but I have one activity class calling a method out of a non-activity class.  When I step through this in the Eclipse debugger, both return true and return false get executed in the if condition that evaluates the netinfo object and the isOnline method returns FALSE, even though the netInfo.isConnected() evaluates to true and is not null.  When I get the value in the if condition of the Calling Class, upon inspection in the debugger I get, "JDI Thread Evaluations has encountered a problem." and it evaluates to true, so I get the success message.   Why am I seeing this behavior and how do I properly evaluate the results of the isConnected method?</p>

<pre><code>Calling Main Activity Class:

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;


 public class Splash extends Activity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

    Connection.context = this;

    // Check Internet Connection 
    if (!Connection.isOnline())
    {
        //throw some message 
        Log.d("Test","Fail!");

    }
    else 
    {
        //state something good.
        Log.d("Test","Success!");

    }


Called Non Activity Class 

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
public class Connection {

public static Context context;

// Check Internet Connection 



public static boolean isOnline() {    




        ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);    
        NetworkInfo netInfo = cm.getActiveNetworkInfo();    
        if (netInfo != null &amp;&amp; netInfo.isConnected()) 
            {return true;} 
        else 
            {return false;}

}
</code></pre>

<p>}</p>
