I have a service that starts on boot and should run while the device is on.
This service has a worker thread that launches an activity (QueryActivity) when a certain event takes place. This activity is launched trough an intent:
private void launchActivity(String msg){
Intent intent = new Intent(getBaseContext(), QueryActivity.class);
intent.putExtra("query", msg);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(intent);
}
The activity will display a text view based on the String msg passed as extra. The activity displays two buttons as well. Let's say YES and NO buttons. The user reads the text and clicks either YES or NO.
I want to send the user's choice (yes or no) back to the service, immediately after the launchActivity method, inside the worker thread.
(...)
launchActivity(str);
String YesOrNo = receiveUserChoice();
(...)
How can I do it?
Thanks.