简体   繁体   English

如何在Android中获取手机壁纸?

[英]How can I get Phone wallpaper in Android?

I am working on an Android application. 我正在开发一个Android应用程序。 How can I get Phone wallpaper in Android? 如何在Android中获取手机壁纸? Please help me. 请帮我。 Give me the sample code example. 给我一个示例代码示例。

You need to use WallpaperManager which, among other things mentioned in the documentation, allows you to get the current wallpaper. 您需要使用WallpaperManager ,除了文档中提到的其他内容之外,还允许您获取当前的壁纸。

The following snippet will get the current wallpaper (or the system default if no wallpaper is set). 以下代码段将获取当前壁纸(如果未设置壁纸,则为系统默认值)。

final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
final Drawable wallpaperDrawable = wallpaperManager.getDrawable();
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
final Drawable wallpaperDrawable = wallpaperManager.getDrawable();

From your activity call 来自您的活动电话

this.getWallpaper(); this.getWallpaper();

壁纸可以使用壁纸类的getDrawable() 如何在Android中获得手机壁纸?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM