您必須重寫onActivityResult,如本文所述。
http://developer.android.com/training/basics/intents/result.html
這是一般流程:
- 你開始另一項活動的結果在您發佈
- 一旦被叫活動結束,應該通過將結果返回給調用活動時尚onActivityResult方法。
您應該檢查結果或檢查藍牙是否在調用ex之後開啓。並根據您現在擁有的信息繼續執行。從文章
代碼片段:
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)
}
}
}
你,直到'onActivityResult()被調用'不要在你的應用程序做任何事情。您可能需要在您的活動中設置一個等待用戶的標誌,以便在用戶作出響應之前,您不會對藍牙執行任何操作。 –
你是否重寫'onActivityResult()'? – codeMagic
相關http://stackoverflow.com/questions/20558689/back-to-previous-activity-with-intent/20558774#20558774 – codeMagic