Is there a way to programmatically lock an app in portrait mode for certain operations, and then resume (and have the app rotate to landscape if the user is holding the devi
I'm reading into your question a bit, but if the problem you are facing is that the reload of the activity causes problems, you can add in the manifest a line to handle the orientation changes yourself. You'll probably need to do this anyway if you want to do something special for the orientation changes, but perhaps just adding the lines will take care of your problems for you:
<activity android:name=".MyActivity"
android:configChanges="keyboard|keyboardHidden|orientation" />
Try this:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//Do your operation
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);