Passing string array between android activities
Bundle b=new Bundle();
b.putStringArray(key, new String[]{value1, value2});
Intent i=new Intent(context, Class);
i.putExtras(b);
Hope this will help you.
In order to read:
Bundle b=this.getIntent().getExtras();
String[] array=b.getStringArray(key);
Passing String array between two class in android application
If you are trying to send a String-array from one Activity to another this can be done in the Intent.
In ClassA:
Intent intent = new Intent(this, ClassB);
String[] myStrings = new String[] {"test", "test2"};
intent.putExtra("strings", myStrings);
startActivity(intent);
In ClassB:
public void onCreate() {
Intent intent = getIntent();
String[] myStrings = intent.getStringArrayExtra("strings");
}
Passing string array to another activity
You have to do the following:
Intent i = new Intent("Activity")
i.putExtra(key, ArrayName)
Intent i = getIntent();
String[] array = i.getExtras().getString(keyname);
and that's it.
Android: Passing String Array over Multiple Activities
You put the code below in a file named data, in your code you then use just it by calling data.array
public class data {
public String[] array = new String[1];
}
But going with just passing through a String[] you shouldn't need bundle.
simply
intent.putExtra("stringArray".String[]);
and get it with
this.getIntent().getStringArrayExtra("stringArray")
How to Pass Array to another activity?
Bundle b = new Bundle();
b.putStringArray(key, new String[]{value1, value2});
Intent i=new Intent(context, Class);
i.putExtras(b);
And for receiveing
Bundle b = this.getIntent().getExtras();
String[] array=b.getStringArray(key);
pass array of string between activities without using Intent or bundle
What is the problem to use array of string instead String?
Your scheme:
in the first activity i have declared a string
String str="abc"; // in activity1.java
and in the second activity am accessing it using this piece of code
String str2=activity1.str; // in activity2.java
Maybe just try it (in your case):
in the first activity i have declared a string
String[] arrayStr = {"abc", "xyz"}; // in activity1.java
and in the second activity am accessing it using this piece of code
String arrayStr2 = activity1.arrayStr; // in activity2.java
Related Topics
Scale Image to Fill Imageview Width and Keep Aspect Ratio
How to Size an Android View Based on Its Parent's Dimensions
Match_Parent Width Does Not Work in Recyclerview
How to Set Internet Options for Android Emulator
The Signing Fingerprint You Specified Is Already Used by Another Android Oauth2 Client
Preferencefragmentcompat Requires Preferencetheme to Be Set
How to Get an Android Wakelock to Work
How to Find If a Particular Package Exists on My Android Device
Defaulthttpclient to Androidhttpclient
Refreshing Data in Recyclerview and Keeping Its Scroll Position
How Does the Mapping Between Android Resources and Resources Id Work
Android Lollipop, Appcompat Actionbar Custom View Doesn't Take Up Whole Screen Width
Missing "<Sdk>/Extras/Google/Google_Play_Services/Libproject" Folder After Update to Revision 30
Removing Log Call Using Proguard
Noclassdeffounderror When Googleanalyticstracker.Getinstance()
What's the Difference Between Fill_Parent and Wrap_Content
Should Have Subtitle Controller Already Set Mediaplayer Error Android