[Solved] What is wrong with this code? App should get the location


The javadoc for onCreate(savedInstanceState) states:

savedInstanceState Bundle: If the activity is being re-initialized after previously being shut down then this Bundle contains the data it most recently supplied in onSaveInstanceState(Bundle). Note: Otherwise it is null.

You are getting an NPE when you call savedInstanceState.getString, with a message that tells you that savedInstanceState.

Solution: modify your onCreate method to cope with the case where there is no saved instance yet; i.e. when savedInstanceState is null.

solved What is wrong with this code? App should get the location