onActivityResult is not being called in Fragment

后端 未结 30 2645
忘了有多久
忘了有多久 2020-11-21 04:28

The activity hosting this fragment has its onActivityResult called when the camera activity returns.

My fragment starts an activity for a result with th

30条回答
  •  一个人的身影
    2020-11-21 05:06

    ADD this

    public void onClick(View v) {   
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT,MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(intent, 1);
    }
    

    when you will replace your code with this above code then automatically your this

    public void onActivityResult(int requestCode, int resultCode,
    @Nullable Intent data){}
    

    Method will Start working

    //No Need to write this code in onclick method
        Intent intent=new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT)
        startActivityForResult(intent,1);
        Toast.makeText(getContext(), "image"+intent, Toast.LENGTH_SHORT).show();
    

提交回复
热议问题