Posts Tagged ‘BroadcastReceiver’
Android: Obtaining the current orientation using a BroadcastReceiver
Posted by Dimitri | Filed under Programming
This Android tutorial explains how to create a Broadcast Receiver that detects screen orientation changes that are triggered by rotating the device. Since screen orientation changes don’t happen every second, it’s better to detect it using a BroadcastReceiver instead of a Service. Both can be used to execute tasks on the background, but the BroadcastReceiver execution will be triggered only when the desired Intent is filtered (in this case, a screen orientation change). Right after the execution, the background task is killed, which is ideal since a BroadcastReceiver can be created to obtain the new screen orientation only after it has changed.