0

I am making an app consisting of two activities. The first activity is a startpage with only a button. When this button is hit, the next activity starts. My drawable file consists of 10 images. The second activity chooses a random image of those ten, and the image is shown on the screen. My question is: Is there a way I can make the shown image into the phones bakcgroundimage. I dont mean the apps background image, but the background on the phone itself. Preferably in java and not in xml. thanks

1 Answers1

1
//Put this code into onCreate method 
//Create array of your images as drawable object and choose random for background.    
LinearLayout ll = new LinearLayout(this);
LayoutParams lparams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
ll.setLayoutParams(lparams);
ll.setBackgroundDrawable(getResources().getDrawable(R.drawable.icon));

setContentView(ll);
overbet13
  • 1,654
  • 1
  • 20
  • 36
iAndroid
  • 951
  • 7
  • 18