0

I'm not using configChanges attribute to my activity in manifest as I need to show a different layout for landscape mode. And saving few primitive data values in onSaveInstanceState() method and getting back in Bundle of onCreate(). Here are my issues :

  1. On click of a button I need to post data to server(using Volley for this). I'm showing a progress dialog during the server communication. App is force closing If I change the device orientation when progress dialog is shown. How can I handle progress dialog state during orientation change? If I use configChanges in manifest, its not force closing but a different layout is not being shown. Please guide me.
  2. I need to show different layout for android tablets only. The screen should not get rotated in other phones. Is there a way to specify configChanges for only other phones? How do I do this?
Gopal Singh Sirvi
  • 4,539
  • 5
  • 33
  • 55
user1670443
  • 461
  • 2
  • 6
  • 17
  • Asked a bazillion times: https://developer.android.com/training/basics/activity-lifecycle/recreating.html – shkschneider Jun 17 '15 at 12:40
  • possible duplicate of [Saving Activity state in Android](http://stackoverflow.com/questions/151777/saving-activity-state-in-android) – shkschneider Jun 17 '15 at 12:41
  • 1
    "How can I handle progress dialog state during orientation change?" -- use a `DialogFragment`. "I need to show different layout for android tablets only. The screen should not get rotated in other phones" -- "phones" and "tablets" are marketing terms, not technical ones. Please explain **completely and precisely** what the difference is, in your mind, between a "phone" and a "tablet". IOW, if you were handed 1000 Android devices, how would you decide which are "phones" and which are "tablets"? – CommonsWare Jun 17 '15 at 12:42
  • to handle an activity state using saved instance state bundle check http://www.quicktips.in/handling-activity-state-using-saved-instance-state-bundle/ – Deepak Swami Aug 25 '15 at 02:41

1 Answers1

1

You should probably add this in your manifest file first (note the configChanges):

<activity android:name=".MyActivity"
          android:configChanges="orientation"
          android:label="@string/app_name">

Then override these two methods and do what you want with the data inside onSaveInstanceState(), onRestoreInstanceState().

Vedran Kopanja
  • 1,259
  • 12
  • 23