I am reading data from bluetooth in main activity using thread. Also I want to show data in second activity continuously.
Asked
Active
Viewed 116 times
0
-
1Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the [How to Ask](http://stackoverflow.com/help/how-to-ask) page for help clarifying this question. – Gustavo Morales May 27 '16 at 14:28
-
Possible duplicate of [Starting a new activity android](http://stackoverflow.com/questions/33267349/starting-a-new-activity-android) – Vucko May 27 '16 at 14:42
-
Possible duplicate of [How do I get extra data from intent on Android?](http://stackoverflow.com/questions/4233873/how-do-i-get-extra-data-from-intent-on-android) – mehrdad khosravi May 27 '16 at 15:24
2 Answers
1
To show the data from main activity in the second, you have to pass it as intent extra.
MainActivity
Intent i = new Intent(this, SecondActivity.class);
i.putExtra(EXTRA1_TEXT, "This value one for ActivityTwo ");
i.putExtra(EXTRA2_TEXT, "This value two ActivityTwo");
SecondActivity
Bundle extras = getIntent().getExtras();
if (extras == null) {
return;
}
// get data via the key
String value1 = extras.getString(Intent.EXTRA1_TEXT);
if (value1 != null) {
// do something with the data
}

Ivan Dokov
- 121
- 6
-
not this way.Thread reading data continuously, i have to pass data to second activity instantly. – asttekin May 27 '16 at 14:54
-
I didn't get it, be more concrete, what do you mean instantly and why? – Ivan Dokov May 27 '16 at 15:02
0
To communicate between activities you could use:
- Custom intents
- Events
- Broadcasts

Artūrs Eimanis
- 578
- 3
- 5
- 22