My problem is this, I have a static method in which I need to call the method startActivity(). I tried creating another class from which I imported its context but that would not work since I still got the error;
'com.example.app5.menuActivity.this' cannot be referenced from a static context.
public static void endDay() {
Context context = getCXT.getAppContext();
// EVENTS
conf.day += 1;
lblDay.setText(String.valueOf(Integer.valueOf(conf.day)));
//conf.dayRunning = false;
//startActivity(new Intent(getActivity(), ReportActivity.class));
context.startActivity(new Intent(this, ReportActivity.class));
gameLoop();
Im a beginner in Java and Android Studio so forgive me if my question seems out of the blue. However I would like to understand why the new intent "this" doesn't work and how I would do instead.
The second class, which I copied from Static way to get 'Context' in Android?.
public class getCXT extends Application {
private static Context context;
public void onCreate() {
super.onCreate();
MyApplication.context = getApplicationContext();
}
public static Context getAppContext() {
return MyApplication.context;
}
}