2013年2月5日 星期二

Set Wallpaper


WallpaperManager wpm = WallpaperManager.getInstance(getBaseContext());
try {
wpm.setResource(R.drawable.lc);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

-----------------------------
If you have image URL then use
WallpaperManager wpm = WallpaperManager.getInstance(context);
InputStream ins = new URL("absolute/path/of/image").openStream();
wpm
.setStream(ins);
If you have image URI then use
WallpaperManager wpm = WallpaperManager.getInstance(context);
wpm
.setResource(Uri.of.image);
In your manifest file:
<uses-permission android:name="android.permission.SET_WALLPAPER"></uses-permission>
share|improve this answer

沒有留言:

張貼留言

Related Posts Plugin for WordPress, Blogger...