You have to override onActivityResult as described in this article.
http://developer.android.com/training/basics/intents/result.html
This is the general flow:
- You start another activity for result in the fashion you posted
- Once the called activity finishes it should return the result to the calling activity via onActivityResult method.
You should check the result or check if bluetooth is turned on after that method is called for ex. and continue your execution based on the information you now have.
Code snippets from the article:
static final int PICK_CONTACT_REQUEST = 1; // The request code
private void pickContact() {
Intent pickContactIntent = new Intent(Intent.ACTION_PICK, Uri.parse("content://contacts"));
pickContactIntent.setType(Phone.CONTENT_TYPE); // Show user only contacts w/ phone numbers
startActivityForResult(pickContactIntent, PICK_CONTACT_REQUEST);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Check which request we're responding to
if (requestCode == PICK_CONTACT_REQUEST) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
// The user picked a contact.
// The Intent's data Uri identifies which contact was selected.
// Do something with the contact here (bigger example below)
}
}
}