Start Activity for Result in Fragment

Frequently used code samples and tutorials
vivekkalady
Site Admin
Posts: 35
Joined: Tue Nov 18, 2014 2:39 pm

Start Activity for Result in Fragment

Postby vivekkalady » Sun Nov 30, 2014 1:35 pm

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.

Code: Select all

@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:

Code: Select all

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



Other Method


use this in activity

Code: Select all

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


the solution is to replace getActivity().startActivityForResult(i, 1); with startActivityForResult(i, 1);

Return to “Tutorials & Examples”

Who is online

Users browsing this forum: No registered users and 1 guest

cron