打开应用程序并更改方向时防止动态壁纸方向发生变化?
我编写的动态壁纸遇到方向问题。基本上,画布将根据其上方打开的应用程序进行旋转。我对此进行了测试,并意识到当我从之前打开的方向已更改的应用程序返回主屏幕时, onSurfaceChanged() 方法将被触发。
我想一个更好的问题是,为什么当应用程序打开并且其方向发生变化时,我的动态壁纸表面会发生变化?有没有办法防止我的动态壁纸方向不断变化?谢谢,希望这是有道理的?
I'm having an orientation issue with a Live Wallpaper that I wrote. Basically the canvas will rotate depending on the application opened above it. I tested this and realized that the onSurfaceChanged() method is firing when I return to the home screen from a previously opened application who's orientation was changed.
I suppose a better question would be, why does my Live Wallpaper Surface Change when an application is opened and it's orientation changed? Is there a way to prevent my Live Wallpaper orientation from ever changing? Thanks, hope that makes sense?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下方法从 android.service.wallpaper.WallpaperService.Engine 类中处理屏幕方向:
...只需相应地处理事件。
您不能将android:configChanges或android:screenOrientation添加到WallpaperService!
(您在创建动态壁纸时使用的)
我会将此添加为“Anirudha”答案的评论,但我没有足够的声誉来这样做。
You can handle screen orientation from within the android.service.wallpaper.WallpaperService.Engine class with the following method:
... just handle the event accordingly.
You CANNOT add android:configChanges nor android:screenOrientation to a WallpaperService!
(Which you are using when creating a live wallpaper)
I would have added this as a comment to "Anirudha"'s answer, but I don't have enough reputation to do so.
当方向改变时,Android 应用程序会重新启动 Activity。
您可以
onConfigurationChanged()
方法。Android application restarts the activity when the orientation changes.
You can either use
onConfigurationChanged()
method is called.