Android - Dealing with a Dialog on Screen Orientation change?

I don't have Reto's book so I can't check the code, but if there is a mistake in the book you can contact him easily on Twitter to discuss it: twitter.com/retomeier.

I don't have Reto's book so I can't check the code, but if there is a mistake in the book you can contact him easily on Twitter to discuss it: twitter.com/retomeier Remember that if the screen orientation changes, your activity is recreated. That means that any variables you set the last time around, which are not static, will be lost after the activity is recreated under the new orientation. My guess is that you hit a NullPointerException here: if(setting.

GetAddForPublicUserNames() == 1){ If so, it is most likely that some user action changes the "setting" variable to something other than null - you need to make sure this is set again when the activity is recreated. The most standard method to store/retrieve the activity state between orientations is detailed here: stackoverflow.com/questions/151777/how-d....

I followed the example in the stack overflow example you supplied, I have added my new code to my question but I am still getting the Null pointer on the exact line you mentioned - if(setting. GetAddForPublicUserNames() == 1){ – Donal Rafferty Jun 10 '10 at 11:11 1 Hmm, I would expect it to work now. Try sticking a breakpoint in your onRestoreInstanceState() method and make sure that "setting" is actually being set before the onPrepareDialog() method tries to use it... – seanhodges Jun 10 '10 at 11:18 It would appear that my setting object is the cause of the null pointers, It must not be getting created/saved or something?

I changed all my variables to be within the class and removed the use of the setting object and the app runs fine now. Q the rest of the evening figuring out why my object isn't getting saved/created :( – Donal Rafferty Jun 10 '10 at 11:59 1 You might be doing a "setting = new Setting()" in the constructor of your Activity (which won't get called the second time). Make sure you have put "this.

Setting = setting" in your addNewSettings() method. – seanhodges Jun 10 '10 at 12:12 Excellent, Thanks for that! – Donal Rafferty Jun 10 '10 at 13:05.

When you change orientation, android restart your activity, you need to save the estate with onSaveInstanceState and recover with savedInstanceState.

If you don't want the activity to be recreated when orientation changes. Insert the following line in the AndroidManifest.xml. Android:configChanges="keyboarddden|orientation example.

For me, this answer was the fastest way to fix all bugs related to screen orientation change. That helped me while integrating Facebook dialogs! The user still can use the hardware keyboard.

– OneWorld Dec 8 '10 at 12:50 It may "seem" to work but only hides the issue. – DDoSAttack Oct 13 at 1:04.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions