global functions accessing system features android
<p>hi i have created a global actions class and created functions inside this class which i'm trying to access inside another activity the problem i'm having is that in eclipse I'm getting coding errors around the functions that access system feature such as getSystemService() and getApplicationContext() does anyone know why or how to let a global class accept system features?</p>

<p>heres what i have so far heres my GloblActions.java</p>

<pre><code>import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;

public class GlobalActions{
        Context mContext;

        // constructor
        public GlobalActions(Context context){
            this.mContext = context;
        }


        public final static boolean isOnline (Context someContext){ {

            Log.v("globals", "isonline");

    ConnectivityManager cm = (ConnectivityManager) someContext.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netInfo = cm.getActiveNetworkInfo();

        if (netInfo != null &amp;&amp; netInfo.isConnectedOrConnecting()) {
            return true;
        }
        return false;
        }

}



        public final static void checkInternet(Context someContext){

                    isOnline(someContext);
                    if(isOnline(someContext) == false){
                       Log.v("globals", "isOnline = false");
                       Intent register = new Intent(someContext.getApplicationContext(), LoginForm.class);
                       someContext.startActivity(register);
                    }
                }



        }   
</code></pre>

<p>heres where i'm using the function in an activity. my goal is is to check internet connection on every activity by just calling the global function and if no connection is found go to an activity that says no internet connection.</p>

<pre><code>import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
import android.os.Handler;
import com.myApp.myApp.GlobalActions;

public class IntroLoader extends Activity {

    public Handler handler;
    public TextView loadText = null;
    public Animation AniFadein = null;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.lo_introloader);
        findViewById(R.id.progressBar1).setVisibility(View.GONE);
        findViewById(R.id.loadTextView).setVisibility(View.GONE);
         GlobalActions.isOnline(null);
         GlobalActions.checkInternet(null);

        handler = new Handler();
        final Runnable fadeIn = new Runnable()
        {
            public void run() 
            {
               animations();
               findViewById(R.id.progressBar1).setVisibility(View.VISIBLE);
               findViewById(R.id.loadTextView).setVisibility(View.VISIBLE);
                         }
        };
        handler.postDelayed(fadeIn, 3000);

        final Runnable aSyncTask= new Runnable()
        {
            public void run() 
            {

               PostTask posttask;
               posttask = new PostTask();
               posttask.execute();

            }
        };
        handler.postDelayed(aSyncTask, 4000);

    }

    public void animations(){

        loadText = (TextView)findViewById(R.id.loadTextView);
        AniFadein = AnimationUtils.loadAnimation(this, R.anim.fadein);  
        loadText.startAnimation(AniFadein); 

    }


  public class PostTask extends AsyncTask&lt;Void, String, Boolean&gt; {

        protected void onPreExecute() {
            super.onPreExecute();

        }

        @Override
        protected Boolean doInBackground(Void... params) {
            boolean result = false;
            publishProgress("progress");
            return result;
        }

        protected void onProgressUpdate(String... progress) {
            StringBuilder str = new StringBuilder();
                for (int i = 1; i &lt; progress.length; i++) {
                    str.append(progress[i] + " ");

                }
        }

            @Override
        protected void onPostExecute(Boolean result) {
            super.onPostExecute(result);
            checkLoginData();
          }
    }

  public void checkLoginData(){

      Intent register = new Intent(getApplicationContext(), LoginForm.class);
      startActivity(register);


  }         



}
</code></pre>
