I am creating an app that has the LinkedIn login. I am following this documentation. But when I click on the login button, the app redirected to the LinkedIn app and asking for login. When successful login it redirected to my app. But nothing happens. Nothing happens on onActivityResult
also.
Below is my code .Login implemented on fragment
LISessionManager.getInstance(getActivity()).init(getActivity(), buildScope(), new AuthListener() {
@Override
public void onAuthSuccess() {
getLinkedInProfile();
Toast.makeText(getApplicationContext(), "success" , Toast.LENGTH_LONG).show();
}
@Override
public void onAuthError(LIAuthError error) {
Toast.makeText(getApplicationContext(), "failed " + error.toString(), Toast.LENGTH_LONG).show();
}
}, true);
//
private static Scope buildScope() {
return Scope.build(Scope.R_BASICPROFILE, Scope.R_EMAILADDRESS);
}
and onActivityResult as follows:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
LISessionManager.getInstance(getActivity()).onActivityResult(getActivity(), requestCode, resultCode, data);
}
Already added hash and package name on LinkedIn developer console. Did I am missing anything? Please help
It is found that the onActivityResult
for LinkedIn sdk triggres on the parent activity rather than fragment onActivityResult
. So you have to write following code into your parent Activity's onActivityResult
for triggering fragment's onActivityResult
.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
yourFragment.onActivityResult(requestCode, resultCode, data);
}