如何在android中检测壁纸的方向
我使用 WallpaperManager.getDrawable() 获取当前壁纸,然后将其转换为位图以执行其他操作。我发现当设备连续旋转时有时会得到错误的壁纸数据。例如,当设备处于横向模式时,壁纸的宽度和高度约为纵向。
有谁知道如何检测壁纸的当前方向或有关壁纸方向的任何相关数据?
I use WallpaperManager.getDrawable()
to get the current wallpaper and then convert it to bitmap to do something else. I find that sometimes I will get the wrong data of wallpaper when the device rotates continuously. For example, the width and height of wallpaper is about portrait when the device is in the landscape mode.
Does anyone know how to detect the current orientation of wallpaper or any related data about wallpaper orientation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我意识到这个答案几乎晚了一年,但希望以下内容能为其他尝试确定壁纸方向的人提供解决方案:
上面的代码将返回一个等于
Surface.ROTATION_0
的整数、Surface.ROTATION_90
、Surface.ROTATION_180
或Surface.ROTATION_270
。注意:
this
指的是WallpaperService
。I realize that this answer is almost a year late, but hopefully the following provides a solution for others trying to determine the orientation of their wallpapers:
the above code will return an integer which is equal to
Surface.ROTATION_0
,Surface.ROTATION_90
,Surface.ROTATION_180
, orSurface.ROTATION_270
.Note:
this
refers to theWallpaperService
.不确定这是否有帮助?
如何处理进度时屏幕方向的变化对话框和后台线程处于活动状态?
Not sure if this helps?
How to handle screen orientation change when progress dialog and background thread active?
在这里您可以获得给定任何上下文的方向:
Here you can get the orientation given any Context: