How can I block device orientation by code

Possible duplicate:
Android: temporarily disable orientation changes in Activity

Me testing on the Samsung Galaxy tab. In this, I created two layout folders for ORIENTATION_LANDSCAPE and ORIENTATION_PORTRAIT with a specific xml layout. In this layout, I have a button, and when I click on it, a progress dialog box starts up (performing some actions using AsyncTask, after that a new intention occurs)
But when the device rotates, when the run dialog works, this dialog and AsyncTask stop and the new layout are loaded . If I understand correctly, I think that onCreateis called when the device is spinning. How can I block the onCreate call while the device is spinning, when My AsyncTask starts?
IN SHOT
How can I lock the orientation of a device by code, for example, "Lock orientation" when I click Thank you

+3
source share
4 answers

Refer to this URL where they clearly explained this.

http://eigo.co.uk/News-Article.aspx?NewsArticleID=103

+6
source

"" onCreate , . , , , onCreate() .

You might want to look at onRetainNonConfigurationInstance () - it may allow AsyncTask to be saved.

0
source

As MisterSquonk said. Unable to block the call onCreate(). You can block the rotation and force the application to a specific orientation, or you need to inform all parts of your application that your activity is restarting.

To make a certain orientation for your application take a look at this answer .

0
source

Source: https://habr.com/ru/post/1782728/


All Articles