I'm making an app that needs a way to get to the next activity(s) randomly. Anyone have a way to do so?
I need it so I'll be able to randomly start the activity(s) by clicking a button, and/or in and "if" statement.
This would be extremely great help! Thank you.
How to Randomly Goto the Next Activity?
Post a Reply
|Oldest Newest Rating|
· October 15, 2015
You can try this one:
Random r = new Random();
case 0: Intent i = new Intent(this, myActivity.class);
case 1: Intent i = new Intent(this, mySecondActivity.class);
case 2: Intent i = new Intent(this, myThirdActivity.class);
argument in method nextInt tells us the highest number that can be randomly selected
I hope it will help you.
· October 14, 2015
How does this sound?
Java has a Random object with next int method for generating integers within a range.
So your range would be the number of activities.
Then use a Switch/Case structure to generate the intent for a specific activity.
Java / Android Development
Very popular language used to create desktop applications, website applets, and Android apps.
|Bucky Roberts Administrator|