You could simply subclass the Cocos2dActivity, so you have a plug&play activity class for upcoming projects.
public class MyActivity extends Cocos2dActivity {
private static Activity instance;
public void onCreate() {
super();
instance = this;
}
public static Activity getInstance() {
return instance;
}
}
And within your isNetworkAvailable() method do the following:
public static boolean isNetworkAvailable() {
Context context = MyActivity.getInstance();
[...] // same code as your first post
}
Don’t forget to declare your new MyActivity class as the main activity within your AndroidManifest.xml