0

Here are some preconditions:

  • the app is designed for smartphones (small, medium, large screens)
  • the app needs to also look so-so on tablets (xlarge screens)
  • the app needs to give users the option to switch between "Stretch to fill screen" and "Zoom to fill screen" when run on a tablet device.

The thing is - when user switches between these modes, the current Activity restarts => goes through the full lifecycle and I don't want that :)

I know that in case of, ie, rotating the device (going from landscape mode to portrait or vice versa) we can use the android:configChange param in the Manifest to prevent the Activity from restarting. But none of the possible options work in the case of Compatibilty Modes.

Any hints, ideas to NOT have the Activity restart when switching between zoom/stretch would be great :)

aMiGo
  • 757
  • 7
  • 10

1 Answers1

0

I know that this answer does not suit your original problem. But why do you want not to restart the activity? The new activity creation is needed to load (maybe new) resources, adjust width / height etc. You could save the data you need to keep and retain it in the onCreate of your activity. Some ways to retain data are listed on this link: http://developer.android.com/guide/topics/data/data-storage.html

Maybe it is an option to look at fragments. If you place a fragment inside an activity you could restart the fragment (delete / add) instead of the activity. This way you won't be dealing with the activity life-cycle.

Bram
  • 4,533
  • 6
  • 29
  • 41
  • I don't know why it is a problem that your complete Activity reloads. Your data should not be in your Activity, but in a Service. If you have any data that took long to load, you can pass it to the new Activity using onSavedInstanceState, see http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState(android.os.Bundle) – Jordi Dec 21 '11 at 14:36