For the app I am building it will randomly select a restaurant (randomResturantName) from my array and print it with toast.
How would I make it so that the user can click on the popup to go to another java page where I will have the chosen restaurant name and other info?
My code:
private void pickRestaurant(int checkedRadioButtonId) {
Random r = new Random();
int randomNumber = -1;
switch (checkedRadioButtonId) {
case R.id.Asian:
randomNumber = r.nextInt(6-1)+1 ;
//1-6
break;
case R.id.middle_eastern:
randomNumber = r.nextInt(9-7) +7 ;
break;
case R.id.Pizza:
randomNumber = r.nextInt(11) + 6;
break;
}
if (DEBUG) Log.i(TAG, "Random number to pick restaurant is: " + randomNumber);
String randomRestaurantName = resArray.get(randomNumber).getName();
Toast toast = null;
if (randomNumber < 0) {
toast = Toast.makeText(myContext, "Select from one of the following:",
Toast.LENGTH_SHORT);
} else {
toast = Toast.makeText(myContext, "Today you will eat at "
+ randomRestaurantName , Toast.LENGTH_LONG);
}
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
Intent intent = new Intent(MainActivity.this,chaCha.class);
intent.putExtra("KEY",randomRestaurantName);
startActivity(intent);
}
chaCha.java
public class chaCha {
private Intent getIntent;
Bundle bundle = getIntent.getExtras();
String randomRestaurantName = bundle.getString("KEY");
}