i’m creating an App preferences class that i can put functions in that i use app wide such as a check internet connection function. what i’m trying to do is import the class into my activity the run one its functions in the on create. does anyone know how to do this?
heres what i’ve got so far
import android.app.Activity;
import android.os.Bundle;
import co.myapp.AppPreferences;
public class Loading extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.lo_loading);
AppPreferences.class.checkInternet()
}
}
heres my AppPreferences.java
public class AppPreferences {
public void checkInternet(){
Log.v("Pref", "checking internet");
}
}
checkInternet()is non-static you need an instance ofAppPreferencesin your activity and use the method on this instance:Another solution is to make
checkInternet()static.