xyz rety
xyz rety

Reputation: 701

How to parse Uri ArrayList<Uri>?

i have an image uri which are store in Arraylist and i put this Arraylist in the intent using putExtra().but i have no idea how to get ArrayList in uri form??

    else if(data!=null){

       clipData = data.getClipData();
       ArrayList<Uri> arrayList = new ArrayList<>();             

        for(int i=0;i<clipData.getItemCount();i++){

             Uri uri=clipData.getItemAt(i).getUri();
             arrayList.add(uri);
       }
         Intent intent=new Intent(getBaseContext(),BackUp_Main.class);
         intent.putExtra("multipleImage",arrayList);
         startActivity(intent);
   }

how can i get Arraylist in Uri from??

Upvotes: 1

Views: 4299

Answers (3)

Tobias Uhmann
Tobias Uhmann

Reputation: 3037

Intent provides methods to put different ArrayLists into it. As Uri implements Parcelable you should use putParcelableArrayListExtra():

intent.putParcelableArrayListExtra("multipleImage", arrayList);
ArrayList<Uri> arrayList = intent.getParcelableArrayListExtra("multipleImage");

Upvotes: 1

Alex Shutov
Alex Shutov

Reputation: 3282

Convert each uri into string and then put string array into intent. You can also extract string arrat and parse uris from it

Upvotes: 0

SGX
SGX

Reputation: 3353

From BackUp_Main activity, you can receive this arraylist like following:

list = (ArrayList<Uri>) getIntent().getSerializableExtra(YOUR_KEY);

Read this article for more: Passing ArrayList through Intent

Upvotes: 3

Related Questions