I have my activity with one boolean variable public.
I set the variable value to true in other class inside MainActivity, but when my application enters the onPause() function, the variable gets the value false, why?
public class MainActivity extends ActionBarActivity {
public boolean detectedState;
public boolean isDetectedState() {
return detectedState;
}
public void setDetectedState(boolean DetectedState) {
this.detectedState = DetectedState;
}
// i have one fragment in MainActivity...
public static class contentFragment extends Fragment{
// Get and set value of Variable
MainActivity activity = new MainActivity();
System.out.println(activity.isDetectedState());
//out is false
activity.setDetectedState(enable);
System.out.println(activity.isDetectedState());
//out is true
// if now i click in home Button for example, the application is with state onPause.. and my out println is false, why?
}
@Override
protected void onPause(){
super.onPause();
System.out.println(isDetectedState());
//here out is false...
}
}