I found out that Android destroys and recreates activities during screen orientation changes. I have an Activity that automatically looks up the device's nominal location and displays it back to the user. This location is stored in a record-keeping object that is used throughout the course of the application. Here's my code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location);
currentLocation = (TextView) findViewById(R.id.textCurrentLocation);
if (savedInstanceState == null)
new LocationDetectionTask(this).execute((Void[]) null);
else
currentLocation.setText(record.getLocation());
Log.d(TAG, "onCreate");
}
(As you might be able to tell, record
represents that data record object).
Is this method of handling screen orientation changes sufficient? By the way, I am not overriding onSaveInstanceState(Bundle)
.
Also, a side question: since LocationDetectionTask
is an AsyncTask
, how do I go about handling screen orientation changes for that?
Edit: I forgot to clarify this. After the LocationDetectionTask
finds the location, it puts it in the record
.