How to Set Wallpaper

From wizarPOS
Revision as of 02:11, 5 June 2020 by Mahong (talk | contribs) (Created page with "== Code snippet== <uses-permission android:name = "android.permission.SET_WALLPAPER"/> <syntaxhighlight lang="java"> public void setWallPaper() { WallpaperManager mWallM...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.