protected void onActivityResult (int requestCode, int resultCode, Intent data) was added in API level 1
Called when an activity you launched exits, giving you the requestCode you started it with, the resultCode it returned, and any additional data from it. The resultCode will be RESULT_CANCELED if the activity explicitly returned that, didn't return any result, or crashed during its operation.
You will receive this call immediately before onResume() when your activity is re-starting.
Parameters:
requestCode - The integer request code originally supplied to startActivityForResult(), allowing you to identify who this result came from.
resultCode - The integer result code returned by the child activity through its setResult().
data An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
1. Start an Activity with a Return Result upon Return
2. In the MainActivity.java file, add the below method to the class.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
// do stuff here. To test, you could Add a Toast
}
3. Compile and run!
Resources:
http://developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)
Popular Posts
- Solution: error: Error parsing XML: unbound prefix
- android:background - Change the Background Color of an EditText
- android:requiresFadingEdge
- Solution: Running Android Lint has encountered a problem Failed
- How to Add a Toast
- Cursor getColumnIndexOrThrow - Get the Index for a Column Name
- Change the line spacing between lines of text in an TextView/EditText, using lineSpacingExtra
- android:ellipsize - Add an ellipsis(...) in a TextView
- How to Register an Activity that Responds to NFC tags for URI's that point to a URL
- android:maxWidth - Set the Maximum Width of TextView