Store the name of all your activities in an array, generate random number and get activity corresponding to random generated number. Sample snippet
String[] title = new String[] { "Act1.class", "Act2.class","Act1.class","Act4.class","Act5.class"};
public String getRandomActivity(){
Random randomGenerator = new Random();
int randomInt = randomGenerator.nextInt(5);// pass number of elements as parameters
return title[randomInt-1];//this should return class name
}
Intent intent = new Intent(this,getRandomActivity())
startActivity(intent)
Store the name of all your activities in an array, generate random number and get activity corresponding to random generated number. Sample snippet
String[] title = new String[] { "Act1.class", "Act2.class","Act1.class","Act4.class","Act5.class"};
public String getRandomActivity(){
Random randomGenerator = new Random();
int randomInt = randomGenerator.nextInt(5);// pass number of elements as parameters
return title[randomInt-1];//this should return class name
}
Intent intent = new Intent(this,getRandomActivity())
startActivity(intent)