简体   繁体   中英

How can I get Phone wallpaper in Android?

I am working on an Android application. How can I get Phone wallpaper in 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.

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();

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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