Fragment disappear after coming back from startActivityForResult

你说的曾经没有我的故事 提交于 2019-12-08 13:40:33

Explicit call from fragment to onActivityResult function as follows

In Parent Activity class, override the onActivityResult() method and even override the same in Fragment Class and call as the following code.

In Parent Class:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.dualPane);
fragment.onActivityResult(requestCode, resultCode, data);
}

In Child Class:

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   //in fragment class callback
    }

my problem has been solved by changing

 Intent intent = new Intent();
 intent.setType("image/*");
 intent.setAction(Intent.ACTION_GET_CONTENT);
 startActivityForResult(
        Intent.createChooser(intent, “Select Album”,
        Home.GALLERY_REQUEST);

to :

Intent intent = new Intent(Intent.ACTION_PICK,
                        android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, Home.GALLERY_REQUEST);

i don't know why but if any one know what is different between starting intent by Intent.createChooser and normally call tell me, thanks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!