How do I use a service to monitor Orientation change in Android

后端 未结 4 1969
梦谈多话
梦谈多话 2020-12-13 15:26

I\'m writing a Widget that will display a countdown timer. I have the widget working the way I want it until I flip the phone from landscape to portrait. My widget does no

4条回答
  •  感情败类
    2020-12-13 15:51

    Service#onConfigurationChanged(Configuration newConfig) works for me. No need to register Receivers for my opinion. I also did not add any filter to AndroidManifest. Did I miss something in the discussion since nobody suggested this solution? My Service is running on foreground.

    Just place inside your service:

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        //Your handling
    }
    

提交回复
热议问题