Android send data from activity to activity using bundle




In Android, UI is shown through an activity(Screen). Movement is utilized to speak to the information to client and permits client communication. In an android application, we can have numerous exercises and they can associate with each other.

Collaboration between numerous exercises should be possible just utilizing Intent. Plans are objects of the android.content.Intent sort. Your code can send them to the Android framework characterizing the parts you are focusing on. In Android application advancement you confront circumstances where you need to send or get your information between one Activity (Screen) to another. In this android instructional exercise I will examine about how to Send or Receive information starting with one Activity then onto the next.

Intent intent1 = new Intent(FirstScreen.this,SecondScreen.class);
 
                startActivity(intent1);

Now if we want to pass this class it must implement the Parcelable interface like that:

public class Person implements Parcelable {
private String name;
private String surname;
private String email;
// Get and Set methods
 
@Override
public int describeContents() {
return hashCode();
}
 
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(name);
dest.writeString(surname);
dest.writeString(email);
}
 
// We reconstruct the object reading from the Parcel data
public Person(Parcel p) {
name = p.readString();
surname = p.readString();
email = p.readString();
}
 
public Person() {}
 
// We need to add a Creator
public static final Parcelable.Creator<person> CREATOR = new Parcelable.Creator<person>() {
 
@Override
public Person createFromParcel(Parcel parcel) {
return new Person(parcel);
}
 
@Override
public Person[] newArray(int size) {
return new Person[size];
}
};

 


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





Be the first to comment

Leave a Reply

Your email address will not be published.


*