How to Set Wallpaper

From wizarPOS
Revision as of 01:46, 10 December 2021 by Mahong (talk | contribs)

Code snippet

 <uses-permission android:name = "android.permission.SET_WALLPAPER"/>
public void setWallPaper() {
    WallpaperManager mWallManager = WallpaperManager.getInstance(context);
    try {
        mWallManager.setResource(R.drawable.wallpaperCos);
        mHandler.obtainMessage(2, "set setWallPaper success...").sendToTarget();
    } catch (Exception e) {
        e.printStackTrace();
        mHandler.obtainMessage(3, "set setWallPaper fail...").sendToTarget();
    }
}

Demo Project

Please get the whole demo.