Possible Duplicate:
Android: Temporarily disable orientation changes in an Activity
Me testing in Samsung Galaxy tab. In that i have made two layout folder for both ORIENTATION_LANDSCAPE and ORIENTATION_PORTRAIT with specific layout xml in it.
In that layout i have a button and on clicking it start a progress dialog (doing some stuff using AsyncTask, after that going to new intent) But when the device is rotated when the progress dialog is working, that dialog and AsyncTask stop and new layout开发者_运维问答 is loaded. If i understood correctly, I think theonCreate
is called when device is rotated
How i can block calling onCreate while rotating device when My AsyncTask start?
IN SHOT
How i can lock Orientation of a device by code, for example Lock Orientation on a button click
Thank you Refer this url , in that they clearly explained to do this
http://eigo.co.uk/News-Article.aspx?NewsArticleID=103
There's an absolutely great answer from CommonsWare regarding How to manage orientation changes with a progressdialog.
It isn't possible to 'block' onCreate in the way you're describing. Whenever there's a configuration change, the current activity is destroyed and recreated so onCreate() will always be called.
You might want to look at onRetainNonConfigurationInstance() however - it can allow storing an AsyncTask.
Like MisterSquonk said. There is no way of blocking the call to onCreate()
. You can either block the rotation and force your application to a certain orientation or you have to inform all parts of your application that your activity is restarting.
To force a certain orientation for you application take a look at this answer.
精彩评论