Android Beginner Tutorial #21 - Send Data Between Activities Using Intents

preview_player
Показать описание
Android Beginner Tutorial #21 - Send Data Between Activities Using Intents

In this video I go over how to send data from one activity to another using an Intent. Using intents to pass data between activities is the best way if you are sending small amounts of data. It's perfect for referencing an item in a ListView that you want to display in a second Activity.

➤My Keyboard:

➤My Microphone:

➤Check out our website:
Рекомендации по теме
Комментарии
Автор

To add the second activity as described around 1:40, you can also right click on the package and left click on new activity instead of new class. This will create the .java the activity to the manifest so you don't have to do it manually. Also, it will automatically create the corresponding layout file.

danielshields
Автор

These are really good. However when I follow your examples, always my layouts always start off as ConstraintLayout and I need to convert them to RelativeLayout, and add the padding and the id. And when you drop objects onto your layout, they seem to stay where they are placed, but even after converting mine to a RelativeLayout all object go to the top left corner and overlap.
How have you got your Android Studio setup such it starts up the way it does in your tutorials ?

turbt
Автор

what if you want to pass the data 1st activity to 3rd (1st->2nd->3rd) or 4th (1st->2nd->3rd->4th) activity ???

radgejoseph
Автор

So... how do you persist data from a database then?
I have a RecylerView that I populate with, say 5 items everytime I reach the end of the screen. But if I press the back button, and then I go in that page again, data will be redownloaded from Firebase. I know back button will trigger onDestroy(); but IDK how to persist my data throughout the app :(

iAdrianT
Автор

I also had to modify the MainActivity.java line 50 to this: intent.putExtra("name", or else lint shows error.

danielshields
Автор

How do you pass objects through intents?

TheWoolliestMammoth
Автор

Is it possible for the intent to hold this data across multiple screens? If i were to save a setting in one screen and want to apply that setting in a activity not directly accessible from the settings activity?

joeharkins
Автор

Why didn't you just simply create a new activity rathar than creating a layout and java class separately

alimansoor