Here is the thing. I do need to do a long process after my MapActivity is started, I have a lot of GeoPoints to add to the map. Everything works fine, but I want to display a ProgressDialog, while my AsyncTask does the job in the background, so the user actually knows that something happens in that few seconds. Again, everything works just fine, until I rotate the phone while the ProgressDialog is alive. No problem I thought, I already dealed with this in another Activity, so I will just pass the Activity to the AsyncTask, which will then invoke the following line before the dialog is shown, so the Context in which I am showing the dialog, wont get destroyed prematurely thus producing a force close:
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
…and I will just invoke this line after my dialog is dismissed:
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
…so the user can rotate his phone again. Here comes my problem: it just won’t work in a MapActivity, it will produce a NullPointerException on the NOSENSOR line. Is there any other way to temporarily disable rotation in MapActivities? I might just fix the whole thing to “portrait”, but that is not what I want to do, if I could do it better.
cheers
To handle the configuration(like orientation change) yourself. Add this to your manifest
in the activity tag.
Then you can handle these config changes by putting following method to your activity