I know that's a question answered before, but no one seems to work and i spend a week on int.
I tried to get my Key Hash from key tool and put them on Facebook app Key hashes, release and debug. No one worked. "(404) Key hash xxxxxxxxxxxx does not match any storeed key hashes" That's rare, my keys are different.
So i tried:
PackageInfo info = getPackageManager().getPackageInfo(
"com.pakage.example",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String result = Base64.encodeToString(md.digest(), Base64.DEFAULT);
Toast.makeText(MainActivity.this , result + result.toUpperCase(), Toast.LENGTH_LONG).show();
}
That return me the same Key Has request by Facebook (xxxxxxxxxxxx), so i added them to Facebook App, but Facebook return me "(404) Key hash xxxxxxxxxxxx does not match any storeed key hashes".
When i removed Facebook App from my device, i was avaliebe to share status via WebDialog.
My final code seems to:
if (FacebookDialog.canPresentShareDialog(parent, FacebookDialog.ShareDialogFeature.SHARE_DIALOG))
{
publishFacebookDialog(points); //FacebookDialog
}
else
{
Session session = Session.getActiveSession();
if (session != null && session.isOpened()) {
publishFeedDialog(points); //WebDialog
}
else
{
Intent intent = new Intent(parent, LoginUsingCustomFragmentActivity.class); //From FacebookSDK demo
parent.startActivityForResult(intent, 666);
}
}
PublishFacebookDialog function:
private void publishFacebookDialog(String puntuacion) {
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(parent)
.setLink("bla")
.setCaption("bla")
.setName("bla")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}
PublishFeedDialog function:
private void publishFeedDialog(String puntuacion) {
Bundle params = new Bundle();
params.putString("name", "bla");
params.putString("caption", "bla");
params.putString("link", "bla");
WebDialog feedDialog = ( new WebDialog.FeedDialogBuilder(parent,Session.getActiveSession(),params))
.setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values, FacebookException error) {
if (error == null) {
final String postId = values.getString("post_id");
if (postId != null) {
} else {
}
} else if (error instanceof FacebookOperationCanceledException) {
// User clicked the "x" button
} else {
// Generic, ex: network error
}
}
})
.build();
feedDialog.show();
}
The LoginUsingCustomFragmentActivity class is the same that FacebookSDK
Tried:
- Remove app from facebook and re add.
- Replace symbols like /_+ etc, like from other answered posts.
- Use the same key hash reported by "(404) Key hash xxxxxxxxxxxx does not ...." on Facebook App.
Any idea?
Lot of thanks.