-1

I am bigginner in android and want to ask. Is there a way to access elements of an array that is declared as public static in different other activities under same package?

virgorian
  • 71
  • 1
  • 3

1 Answers1

0

You can use intent on accessing value from another class

Class1:

Intent intent = new Intent(this, ClassB);
String[] data = new String[] {"value1", "value2"};
intent.putExtra("strings", data);
startActivity(intent);

Class2:

public void onCreate() {
  Intent intent = getIntent();
  String[] data = intent.getStringArrayExtra("strings");
}
Dyrandz Famador
  • 4,499
  • 5
  • 25
  • 40
  • @Famador what will be the case if array consists of imageviews? – virgorian Mar 03 '15 at 04:49
  • you can Convert it to a Byte array before you add it to the intent, send it out, and decode. visit this: http://stackoverflow.com/questions/11010386/send-bitmap-using-intent-android – Dyrandz Famador Mar 03 '15 at 05:02