/**
* Attempts to resolve a connection failure. This will usually involve
* starting a UI flow that lets the user give the appropriate consents
* necessary for sign-in to work.
*/
void resolveConnectionResult() {
// Try to resolve the problem
debugLog("resolveConnectionResult: trying to resolve result: " + mConnectionResult);
Toast.makeText(mBA.context, "Before Has Resolution", Toast.LENGTH_SHORT).show();
if (mConnectionResult.hasResolution()) {
// This problem can be fixed. So let's try to fix it.
debugLog("result has resolution. Starting it.");
int requestCode;
Toast.makeText(mBA.context, "Before ion", Toast.LENGTH_SHORT).show();
ion = new IOnActivityResult() {
@Override
public void ResultArrived(int resultCode, Intent intent) {
if (resultCode == Activity.RESULT_OK) {
Toast.makeText(mBA.context, "Got OK Result", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(mBA.context, "Got Bad Result", Toast.LENGTH_SHORT).show();
}
}
};
BA pBa = mBA.processBA;
try {
pBa .startActivityForResult(ion, null); //<-- passing null instead of an intent
} catch (NullPointerException npe) {
//required...
}
BA.SharedProcessBA sba = pBa.sharedProcessBA;
try {
Field f = BA.SharedProcessBA.class.getDeclaredField("onActivityResultCode");
f.setAccessible(true);
requestCode = f.getInt(sba) - 1;
//requestCode holds the value that should be used to send the intent.
//Toast.makeText(mBA.context, Integer.toString(requestCode), Toast.LENGTH_SHORT).show();
} catch (Exception e) {
throw new RuntimeException(e);
}
try {
// launch appropriate UI flow (which might, for example, be the
// sign-in flow)
mExpectingActivityResult = true;
mConnectionResult.startResolutionForResult(mBA.activity, requestCode);
} catch (SendIntentException e) {
// Try connecting again
debugLog("SendIntentException.");
connectCurrentClient();
}
} else {
// It's not a problem what we can solve, so give up and show an
// error.
debugLog("resolveConnectionResult: result has no resolution. Giving up.");
giveUp();
}
}