1

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??

xyz rety
  • 671
  • 2
  • 11
  • 22

3 Answers3

3

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

Community
  • 1
  • 1
xxx
  • 3,315
  • 5
  • 21
  • 40
1

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");
Tobias Uhmann
  • 2,757
  • 2
  • 25
  • 35
0

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

Alex Shutov
  • 3,217
  • 2
  • 13
  • 11