Hello I build an application with an imageswitcher and a button. When I press the button I need to set as wallpaper the current image displayed in the imageswitcher.
How can I get the full image path from the current displayed image? (like R.drawable.myimage)
I found getDisplayedChild() but is not doing what I need.
Here is my code:
WallpaperManager myWallpaperManager
= WallpaperManager.getInstance(getApplicationContext());
try {
int imageid = iSwitcher.getDisplayedChild();
myWallpaperManager.setResource(imageid);
alerta();
System.out.println(pics[imageid]);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Got it :)
If anyone need this I created a new int variable and assigned to it the image id of the clicked image from gallery.
iSwitcher.setImageResource(pics[arg2]);
foto = arg2;
and when I click my button I read "foto" var.
myWallpaperManager.setResource(pics[foto]);