There are, however, things that you need to care about, like: what if you have data which you want to transfer between Activities, or how to handle those data when receiving them, or how to 'send' the data to another Activity.
Data management between Activities will be covered in another post. For now, let's just show how easy is to start new Activity from the existing one.
First of all, you need to create a new Intent. It is something like token which is signalizing the creation of a new Activity. It can even carry your data to new Activity. New Intent is created like this:
Intent intent = new Intent(this, NovoUlaganjeActivity.class);
As you can see, you need to specify the context and new Activity which is going to be created and started. In order to execute the creation and starting of new Activity, just add this line to your code:
startActivity(intent);
And that is it.
If you need to close the newly created Activity and return to the one which started it, just call
finish();
in your new Activity.
Nema komentara:
Objavi komentar