0

I am reading data from bluetooth in main activity using thread. Also I want to show data in second activity continuously.

asttekin
  • 11
  • 1
  • 1
    Please 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 Answers2

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
0

To communicate between activities you could use:

  1. Custom intents
  2. Events
  3. Broadcasts
Artūrs Eimanis
  • 578
  • 3
  • 5
  • 22