Only want to block orientation until all the data is loaded in my view. So I thought about the following code but it doesn\'t work.
private class task extends As
You are doing this because you have found that your async task is killed during the activity destroy and recreate. Am I right?
The correct way of handling this is not to lock the orientation whilst your task is running. I don't agree that the setRequestedOrientation
approach not working is a bug; rather the idea of locking an activities orientation and then unlocking from an async task is unsupported.
I have gone to explain in some detail how to ensure your async task is not killed by disassociating it with your activity lifecycle. Looking back on the solution I provided I have since discovered better ways of checking a service is running (Inter Process Control and bound services) but the overarching principle applies. Host the async task in an orientation unaware android.app.Service
and allow the async task to only communicate with the service and the service to only communicate with those activities which have bound to it.
I think this is a more standard approach.