Question

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.savedInstanceState = savedInstance;
    }
@Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        try {
            Log.d("Equals?",savedInstanceState.equals(this.savedInstanceState));
        } catch (Exception e) {
            Log.d("Equals?",savedInstanceState==this.savedInstanceState);
        }
    }

Will this always\never or only on some cases log true?

EDIT: after seeing Henry's comment, lets address my question as if Intent has overriden its equals and it does compare those objects content, not by references...

Was it helpful?

Solution

onCreate(Bundle) called to do initial creation of the fragment.

onActivityCreated(Bundle) tells the fragment that its activity has completed its own Activity.onCreate().

so we can say that Bundle savedInstanceState are same at both places.

for more visit

http://developer.android.com/reference/android/app/Fragment.html

http://developer.android.com/guide/components/fragments.html

you wrote

@Override
    public void onCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        this.savedInstanceState = savedInstance;
    }

i do not understand which lifecycle mehod is onCreated i think it should be onCreate and the lines should be

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
....}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top