startActivityForResult is not working in Fragment

后端 未结 2 1792
北荒
北荒 2020-12-30 12:26

I am currently working with with Fragment. I want to pick Image from gallery & display it onTo fragment class. But here startActivityForResult() is not working in Fragm

2条回答
  •  被撕碎了的回忆
    2020-12-30 12:49

    In Activity class:

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data){
        super.onActivityResult(requestCode,resultCode,data);
    }
    

    In Fragment :

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data){
        //  Handle activity result here  
    }
    

    start activity for result from fragment:

    Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    startActivityForResult(intent, 1); 
    

提交回复
热议问题