Xamarin.Android OnActivityResult not being called inside a Fragment

前端 未结 4 435
梦毁少年i
梦毁少年i 2021-01-14 04:46

It appears as if OnActivityResult does not get called after accepting the picture taken from the camera.

Am I calling StartActivityForResult() wrong?, or is

4条回答
  •  死守一世寂寞
    2021-01-14 05:22

    Check for request code is same as provided for startActivityForResult(intent, 0) here 0 is request code.. eg if you put 999 here insted of 0 ..then in onActivity result method check for requestcode == 999. it is used to check if the intent is the same as asked for and nothing other than that..

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data); 
        if (requestCode == 0 && resultCode == RESULT_OK) { // ADD THIS
        // Get Data and do something with it 
        }
    }
    

提交回复
热议问题