Search code examples
javaandroidparcelableonactivityresult

Getting a value from an arraylistparcelable


I have a class called

public class Contact implements Parcelable {
      public String id,name,phone,label;

In my mainactivity I have

public void onActivityResult(int requestCode,int resultCode,Intent data){
        super.onActivityResult(requestCode, resultCode, data);

        if(requestCode == CONTACT_PICK_REQUEST && resultCode == RESULT_OK){

            ArrayList<Contact> selectedContacts = data.getParcelableArrayListExtra("SelectedContacts");

            String display="";
            for(int i=0;i<selectedContacts.size();i++){

                display += (i+1)+". "+selectedContacts.get(i).toString()+"\n";

            }
            contactsDisplay.setText("Selected Contacts : \n\n"+display);

        }

    }

I want to send a message to the phone numbers list in my arraylist when I click a Button.
I already have the SmsManager code, I just don't know how to get the phone number values on the arraylist.
I'm new to Android programming.


Solution

  • i just dont know how to get the phone number values

    That's just standard Java member variable access

    selectedContacts.get(i).phone