title: Sending a android.content.Context parameter to a function with JNI
body: <p>I am trying to create a method that checks for internet connection that needs a Context parameter. The JNIHelper allows me to call static functions with parameters, but I don't know how to "retrieve" Cocos2d-x Activity class to use it as a parameter.</p>
  
  <pre><code>public static boolean isNetworkAvailable(Context context) {
      boolean haveConnectedWifi = false;
      boolean haveConnectedMobile = false;
      ConnectivityManager cm =
          (ConnectivityManager) context.getSystemService(
      Context.CONNECTIVITY_SERVICE);
      NetworkInfo[] netInfo = cm.getAllNetworkInfo();
      for (NetworkInfo ni : netInfo) {
          if (ni.getTypeName().equalsIgnoreCase("WIFI"))
              if (ni.isConnected())
                  haveConnectedWifi = true;
          if (ni.getTypeName().equalsIgnoreCase("MOBILE"))
              if (ni.isConnected())
                  haveConnectedMobile = true;
      }
      return haveConnectedWifi || haveConnectedMobile;
  }
  </code></pre>
  
  <p>and the c++ code is</p>
  
  <pre><code>JniMethodInfo methodInfo;
  if ( !JniHelper::getStaticMethodInfo( methodInfo,
      "my/app/TestApp", "isNetworkAvailable", "(Landroid/content/Context;)Z")) {
          //error
          return;
  }
  CCLog( "Method found and loaded!");
  methodInfo.env-&gt;CallStaticBooleanMethod( methodInfo.classID,
  methodInfo.methodID);
  methodInfo.env-&gt;DeleteLocalRef( methodInfo.classID);
  </code></pre>