Want to be in the current Activity in your onActivityResult receives the returned data
Results onActivityResult didn't be called back,,, I ask what reason be?
Public class MainActivity extends AppCompatActivity {
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
AAR. SetOpenAlbumListener (new AAR. OpenAlbumListener () {
@ Override
Public void openAlbum () {
Intent intentToPickPic=new Intent (Intent. ACTION_PICK, null);
IntentToPickPic. SetDataAndType (MediaStore. Images. Media. EXTERNAL_CONTENT_URI, "image/*");
MainActivity. This. StartActivityForResult (intentToPickPic, 1000);
}
});
@ Override
Protected void onActivityResult (int requestCode, int the resultCode, Intent data) {
//get photo
Try {
//the uri is an Activity on the returned
ImageUri=data. GetData ();
System. The out. Println (" uri="+ imageUri);
} the catch (Exception e) {
e.printStackTrace();
}
}
}
CodePudding user response:
Super. OnActivityResult (requestCode, the resultCode, data); What do you parent@ Override
50 protected void onActivityResult (int requestCode, int the resultCode, Intent data) {
51. Super onActivityResult (requestCode, the resultCode, data);
52//RESULT_OK, judge another activity is over data input function, Standard activity result:
53//operation succeeded. The default value is 1
54 the if (the resultCode==2) {
55 the if (requestCode==requestCode) {
56 int three=data getIntExtra (" three ", 0);
57//set the display of the numerical results show that box
58 result. SetText (String. The valueOf (three));
59}
60}
61}
62
CodePudding user response:
Upstairs said is not the solutionCodePudding user response:
Solve the reason is that only the outside of the aar activity to receive onActivityResult callback is invalid and call if the context also is in the aar