I'm following this tutorial and everything seems fine until the LinkedIn app goes back to my Activity (in onResultActivity). I get a resultCode of 2, which I can't figure out what it means. This resultCode is also not handled within the LinkedIn sdk code!
Has anyone come across this? Or had it run successfully?
Result code "2" indicated an error is occurring. You should be able to see more information about the problem from the errorInfo
and errorDesc
objects returned.
Try this way I got my solution with this process of creating SHA
try {
PackageInfo info = context.getPackageManager().getPackageInfo(
packageName, PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
// writtenToFile("FB_KEY_HASH.txt",
// Base64.encodeToString(md.digest(),
// Base64.DEFAULT).toString(), false);
if (AppUtills.showLogs)
Log.v(pageName,
"KeyHash:"
+ Base64.encodeToString(md.digest(),
Base64.DEFAULT));
}
} catch (Exception e) {
e.printStackTrace();
}
I had the same issue. My problem was when generating the debug key I thought the password prompt was for me to password protect the debug.keystore file. Actually it is prompting you for the password that Android studio used when creating the file which is android. If you put in the wrong password the keytool -exportcert command returns no errors. However if you try keytool -list ~/.android/debug.keystore it will let you know if the password is wrong.
I got the same error while integrating linkedin in android app. This error is due to invalid hash key.Generate key hash either by development keystore aand release keystore.
Development Keystore Syntax : keytool -exportcert -keystore ~/.android/debug.keystore -alias androiddebugkey | openssl sha1 -binary | openssl base64
It will prompt for password : give password android you will get correct keyhash.
来源:https://stackoverflow.com/questions/29068428/linkedin-sdk-init-bad-resultcode