In an Android app, is there anything wrong with the following approach:
public class MyApp extends android.app.Application {
private static MyApp instan
Application Class:
import android.app.Application;
import android.content.Context;
public class MyApplication extends Application {
private static Context mContext;
public void onCreate() {
super.onCreate();
mContext = getApplicationContext();
}
public static Context getAppContext() {
return mContext;
}
}
Declare the Application in the AndroidManifest:
Usage:
MyApplication.getAppContext()