Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getLastNonConfigurationInstance always returning null

HashMap myMap = (HashMap) getLastNonConfigurationInstance();

myMap is always null. getLastNonConfigurationInstance() returns an object. My map has two keys "symbol" and "name".

public Object onRetainNonConfigurationInstance()
    {
        HashMap myMap = new HashMap();
        myMap.put("symbol", this.symbol);
        final Object data = myMap;
        return data;
    }
like image 942
Sheehan Alam Avatar asked Dec 04 '22 11:12

Sheehan Alam


1 Answers

I faced the same issue. Looks like calling getLastNonConfigurationInstance() in anything other than onCreate() returns null. I moved the statement to onCreate() method and voila..it returned what I expected it to return.

like image 111
MKG Avatar answered Jan 14 '23 12:01

MKG