1

I want to pass a ArrayList from one activity to other. I have found this link for pass arraylist from one activity to other useful.

But when I am using

    ArrayList<String> hyperlinks = new ArrayList<String>();
                           ...

    Intent myIntent=new Intent(Player.this,VideoActivity.class);
                    Bundle mBundle = new Bundle();  
                    mBundle.putStringArrayListExtra("hyperlinks", hyperlinks);
                    //mBundle.putString("filePath", hyperlinks.get(0));  
                    myIntent.putExtras(mBundle); 
                    Player.this.startActivity(myIntent);

Then I am getting error at mBundle.putStringArrayListExtra , Saying that The method putStringArrayListExtra(String, ArrayList) is undefined for the type Bundle

Please guide me how to do this??

Thanks

Community
  • 1
  • 1
Vishal
  • 673
  • 3
  • 12
  • 24
  • 3
    please read the Bundle and Intent doc – Blackbelt Oct 23 '12 at 12:01
  • 2
    it has been answered before http://stackoverflow.com/questions/4029969/problems-with-putstringarraylistextra-in-android – Gaurav Vashisth Oct 23 '12 at 12:03
  • [**Please See this Blog. This Can Help You**](http://startandroiddevelopment.blogspot.in/2013/11/how-to-pass-boolean-int-string-integer.html) –  Nov 04 '13 at 04:45

3 Answers3

2

check into Application. You can extend your own application, and save the arraylist here

check out ==> Extending Application to share variables globally

Community
  • 1
  • 1
noxius
  • 144
  • 10
2

There's lots of ways to do it, but have you tried:

myIntent.putStringArrayListExtra(key, hyperlinks);

Also, the Bundle object has

 putStringArrayList
Joe Plante
  • 6,308
  • 2
  • 30
  • 23
1

Bundle Documentation clearly indicating that putStringArrayList(String, ArrayList) is method of Bundle class, but not putStringArrayListExtra()

http://developer.android.com/reference/android/os/Bundle.html#putStringArrayList(java.lang.String, java.util.ArrayList)

Also, please Check import declarations, and check if Proper Bundle class has been imported or not.

Package of Bundle class should be:

import android.os.Bundle;
jeet
  • 29,001
  • 6
  • 52
  • 53