How do I tell when a configuration change is happening in Froyo?

前端 未结 5 1511
梦谈多话
梦谈多话 2021-02-08 13:18

In my app, I want a media file to play, and to keep playing if the user rotates the screen (destroying the Activity), but I want it to stop playing if the user moves to a differ

5条回答
  •  一整个雨季
    2021-02-08 14:07

    You can try listening for the ACTION_CONFIGURATION_CHANGED intent and setting an internal flag indicating the pause is from a configuration change.

    I'm not sure if you will receive the intent in time or that you will be guaranteed it will arrive in time as it is probably asynchronous. Might be worth a try though.

提交回复
热议问题