I have an Activity that if opened, it displays random background.
I was wondering if having a background with sound is possible in android. Like if the background is Nature.jpg then the background audio is BirdsChirping.mp3. (So it matches the ambiance of the background.)
Like this:
> Nature.jpg = BirdsChirping.mp3
> Ocean.jpg = Waves.mp3
> Plane.jpg = JetEngineSound.mp3
Here is my current code:
// RANDOM IMAGE
int[] photos={R.drawable.nature, R.drawable.ocean};
ImageView image= (ImageView) findViewById(R.id.main_activity_bg);
Random ran=new Random();
int i=ran.nextInt(photos.length);
image.setImageResource(photos[i]);
Aucun commentaire:
Enregistrer un commentaire