How to detect orientation change in home screen widget?
- by kknight
I am writing a home screen widget and want to update the home screen widget when the device orientation changes from portrait to landscape or the other way. How can I make it?
Currently, I tried to reigster to CONFIGURATION_CHANGED action like the code below, but the Android didn't allow me to do that by saying "IntentReceiver components are not allowed to register to receive intents". Can someone help me? Thanks.
public class MyWidget extends AppWidgetProvider {
@Override
public void onEnabled(Context context) {
super.onEnabled(context);
this.registerReceiver(this, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
}