I know how to lock an app to portrait mode forever:
<activity
android:screenOrientation="portrait"
android:name=".MyActivity"></activity>
I now want to make this a user preference. That is, instead of the user checking/unchecking Settings > Display > Auto-rotate screen for the entire phone, I want to have a similar checkbox for my application only.
How do I do that programmatically?
Thanks to this answer, I came up with the following: