Created
June 4, 2014 03:13
-
-
Save douzifly/44ce824fafc49900ddac to your computer and use it in GitHub Desktop.
override dispatchACtivityResult
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void dispatchActivityResult(String who, int requestCode, int resultCode, | |
Intent data) { | |
if (who != null) { | |
Activity act = mLocalActivityManager.getActivity(who); | |
// if (true) Log.v( | |
// TAG, "Dispatching result: who=" + who + ", reqCode=" + requestCode | |
// + ", resCode=" + resultCode + ", data=" + data | |
// + ", rec=" + act); | |
if (act != null) { | |
// act.onActivityResult(requestCode, resultCode, data); | |
callActivityResult(act, requestCode, resultCode, data, false); | |
return; | |
} | |
} | |
// super.dispatchActivityResult(who, requestCode, resultCode, data); | |
callActivityResult(this, requestCode, resultCode, data, true); | |
} | |
void callActivityResult(Activity act, int requestCode, int resultCode, Intent data, boolean superClass) { | |
Class c ; | |
if (superClass) { | |
c = act.getClass().getSuperclass(); | |
} else { | |
c = act.getClass(); | |
} | |
try { | |
Method mOAR = c.getDeclaredMethod("onActivityResult", int.class, int.class, Intent.class); | |
mOAR.setAccessible(true); | |
mOAR.invoke(act, requestCode, resultCode, data); | |
} catch (NoSuchMethodException e) { | |
e.printStackTrace(); | |
} catch (IllegalAccessException e) { | |
e.printStackTrace(); | |
} catch (IllegalArgumentException e) { | |
e.printStackTrace(); | |
} catch (InvocationTargetException e) { | |
e.printStackTrace(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment