how to use variable while calling new activity in intent?

android, android-activity

Solution

You cant pass a String in as the parameter it has to be an Activity.

Use an if or switch statement to switch between the different selections you have.

Something like this maybe....

Intent i; 
switch(var)
case:Login
i = new Intent(Favorites.this, Login.class); 
break; 
case:Signup
i = new Intent(Favorites.this, Signup.class);
break;   
case:More
i = new Intent(Favorites.this, More.class);
break; 


startActivity(i); 

Problem

i have following code to call new activity now i want to use variable to call new activity String var1,var2,var3; var1="Login"; var2="Signup"; var3="more"; ``` Intent i; i = new Intent(Favorites.this, Login.class); --> login.class with var startActivity(i); ``` can any one guide me how to achieve this???

Original source