Quantcast
Channel: Another Android Blog » Android Development
Viewing all articles
Browse latest Browse all 10

Launch New Activity

$
0
0

Intent takes two parameters in the most basic example. The first parameter is the class calling the new Activity (Intent). The second parameter is the class name of the Activity to launch.

Intent intent = new Intent(this, ActivityClassToLaunch.class);
startActivity(intent);

Using finish() will close the calling activity. This will keep the user from using the back button to return to the original activity. For example, collecting form data and saving it to a database without using finish() on the form activity may allow the user to duplicate the data by hitting the back button and again hitting submit. Using finish() is an easy way to prevent this.

Cheers,
Randall


This post is part of a new snippet series I will be adding to my blog. Basically, it’s a way for me to quickly look up code when my brain decides to bury it. If I have to look it up more than once, I’ll try to add it here as well.

Viewing all articles
Browse latest Browse all 10

Trending Articles