Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKayondo Martin
7,481 PointsHow do I get to resume previous activity without knowing the previous activity details at all?
I can't find a way to resume.
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class LandingActivity extends AppCompatActivity {
public Button relaunchButton;
// Some previous code omitted for brevity
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_landing);
// Some previous code omitted for brevity
relaunchButton = (Button)findViewById(R.id.relaunchButton);
relaunchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Add your code here!
}
});
}
}
1 Answer
Ben Deitch
Treehouse TeacherHey Kayondo!
You don't need to know anything about the previous Activity. You just need to finish up the current Activity and Android will automatically jump you back to the previous Activity. To finish the Activity you can use the 'finish' method:
// Add your code here!
finish();
Kayondo Martin
7,481 PointsKayondo Martin
7,481 PointsThank you, Ben