Passing Intent data from Activity to Class
2 answers
In android, you can send data via Intent or Intent followed by a Bundle:
Intent i = new Intent(current_activity.this, linked_class.class);
i.putextra("Key", value);
And get the value (let's say string value) in another class like:
String value = getIntent.getExtra("String key which you used when send value");
Option 2 :
class yourClass {
public static String _utfValue = "";
void sendValue(){
_utfValue = "some value";
}
}
And select this value in your java class, for example:
String value = A._utfValue ;
Option 3 . You can use SharedPreference to store a value and get it from another class.
Option 4 . You can use static method with some return value and select the method in your java class via class name.
All options are rough. So just check it out, hope one of them helps you.
+5
user8259253
source
to share