0

Imagine the follow situation:
MainActivity starts a thread to receive bluetooth data. If the user press back button the follow sequence happens: onPause() -> onStop() -> onDestroy(). The onDestroy interrupts the thead created by activity and the program finish completely.

But, if the user press home button the sequence is : onPause() -> onStop(). and the activity is no longer visible. But the thread still running.

What i want to do is , when some BT data is received by by the thread, the MainActivity becomes visible again (resume) without user intervention.

Anyone know how to do it?

Thanks.

Abdul Rahman
  • 2,097
  • 4
  • 28
  • 36
  • The description is way to vague. What OS, what thread primitives are you using? Where does `onStop`, etc. API comes from? – Nikolai Fetissov Jun 22 '12 at 02:48
  • It is never a good user experience to pop up an Activity that the user didn't explicitly start. You should look at posting a Notification instead to get the user's attention. – devunwired Jun 22 '12 at 04:07
  • its Android 2.3.3 smartphone. The onStop/resume/pause e etc cames from the android api. – Amauri Mocki Jun 22 '12 at 12:43

1 Answers1

0

You should write a service that runs in the background and on certain event (in your case file recieved through Bluetooth) call the app that you want to run. That'll be one way to approach this. There might be some other solutions but this one will not drain user's battery.

Mayank
  • 8,777
  • 4
  • 35
  • 60