Reputation: 147
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode,resultCode,data)
if (requestCode == Selectedimage && resultCode == RESULT_OK && data != null) {
Uri pickedImage = data.getData();
Intent send= new Intent(Selection.this,Imagepage.class);
send.putExtra("pickedImage",pickedImage.toString());
startActivity(send);
}
}
what is the use of adding that super.onActivityResult
line ? and also when am adding that, its showing some error.
Upvotes: 1
Views: 2613
Reputation: 3658
The call does not really do anything (link to source code) so you can omit it if it's giving problems.
The fact that it does is weird considering the empty super implementation though.
Upvotes: 0
Reputation: 11234
First of all, if you get an error - always show logcat. Secondly, if this method is declared in the class extending Activity
, there is no need to call super
there since this method is empty in the Activity
class:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
Upvotes: 2
Reputation: 1512
The onActivityResult()
is a little like onOptionMenuSelected()
, in the way that:
Therefore, in your Fragment's onActivityResult()
, you should first check if the requestCode
meets what you set before, if so, deal with the data and return. If not, just return with super.onActivityResult()
.
A simple sample may look like:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case SELECT_FILE_TO_UPLOAD:
// upload a file
return;
case SELECT_FILE_TO_DELETE:
// delete a file
return;
default:
super.onActivityResult(requestCode, resultCode, data);
}
}
Upvotes: 3