We are facing issue with Android application.There is one class named SingleTon which Extends Application and we are using it for State manager.when Application running in background and if I open push notification I am not able to access the Singleton class due o context is null, and that's why application is crashed.Same thing happens if application is on stand by mode. Here, I have mentioned my SingleTon class Code:
public class StateManager extends Application {
public String FirstName;
public String LastName;
private static StateManager instance;
public static synchronized StateManager getInstance() {
return instance;
}
public String getFirstName() {
return FirstName;
}
public void setFirstName(String firstName) {
FirstName = firstName;
}
public String getLastName() {
return LastName;
}
public void setLastName(String lastName) {
LastName = lastName;
}
@Override
public void onCreate() {
super.onCreate();
instance = this;
Parse.enableLocalDatastore(this);
Parse.initialize(this, "xxxx", "xxxxx");
ParseInstallation.getCurrentInstallation().saveInBackground();
}
@Override
public void onTerminate() {
instance =this;
super.onTerminate();
}
}