I have a class that implements 'Serializable' but i am unable to get the context of my main activity in it. Here is my code for this class:
public class Game implements Serializable{
private String name;
private ColorTheme theme;
private int distance = 0;
private int score = 0;
boolean boom = false;
protected Context context;
public Game(MainActivity context){
this.context = context.getApplicationContext();
}
After this i thought i get the context and then what i want is that when the score is greater than 1 then the app should closed.
score = (i+1);
if (score >1)
{
}
I want to close my game inside this condition but it is not giving me any option to finish the context. Please help me where i am wrong. I think the context is not successfully implemented in this Serializable class. Help needed