How To Set Image As Wall Paper In Viewpager App?
Edited code after following this link ...Set wallpaper from ViewPager .I developed simple viewpager app along with the background music. However, I want to modify my app so that im
Solution 1:
First add this Permission to the Manifest
<uses-permissionandroid:name="android.permission.SET_WALLPAPER">
Now for some code.
imageview.setOnClickListener(newView.OnClickListener() {
publicvoidonClick(View view) {
WallpaperManagermyWallpaperManager= WallpaperManager.getInstance(context);
try {
myWallpaperManager.setResource(GalImages[position]);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
Explantion : This will set that the Image will be clickable , when the image is clicked it will set the phone Wallpaper with the selected drawable.
getApplicationContext()
is the Context from the Activity. This changes will take place inside the Adapter.
Activity add this variable
int currentPosition;
Post a Comment for "How To Set Image As Wall Paper In Viewpager App?"