Implementing facebook in android - android

Hi i am using new sdks of facebook for publishing.Everything is working fine except that i am unable to login from my android app if already facebook is installed means that if facebook application is n*ot installed on phone* i can sucessfully post data to facebook through my mobile application but if user has installed the facebook app , i cannot post my data.
Kindly help me in this stuff..
Sorry for incorrect English..

Looking at your problem I suggest you look at this.
The crux of the problem is that the keytool on windows messes up the key hash.
Do
"keytool -export ..." instead of "keytool -exportcert ...";
Both generate keys but the second one messes it up.
You can also get the key by putting this in your activity
try {
PackageInfo info = getPackageManager().getPackageInfo("com.yourcompany.client", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("Hash Key:", Base64.encode(md.digest()));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}

Related

"This app has no Android key hashses configured. Configure your app key hashes at ~~

I tried to use Facebook login in my app.
But I have this problem only on my physical android device. (not a virtual device)
How can I fix it?
You need to setup the key hash in the facebook App Dashboard. To get the signature key hash,
just call the method below in your App in a release build (no publishing required) and run your app - in Logcat you can see the output.
After this you can remove the method.
If you want it also to work for debugging purposes do the same in a debug release. Because the hashes are different.
private void printKeyHash() {
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName() , PackageManager.GET_SIGNATURES);
for(Signature signature:info.signatures){
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.i("Signature", Base64.encodeToString(md.digest(), Base64.DEFAULT));// <--- signature
}
} catch(Exception e) {
e.printStackTrace();
}
}
In Facebook App Dashboard enter the hashes. And don't forget to switch the App Mode to live after your app is released

There was a something wrong with facebook login with different accounts?

Firstly I want to say I search more than 1 week about this but I ve not found the solution what I need.
My simple target : I want to login facebook with my android app.
What I did : I found many sample to login facebook and I tried all of them.(I give codes which belongs to one of them) I create developer facebook account. And I add platform for android. It gives me App ID and secret. And I generate key hash in two methods(I have same the key hash for two of them) :
1.
$ keytool -exportcert -alias androiddebugkey -keystore "C:\Documents and Settings\Administrator.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary |"C:\OpenSSL\bin\openssl" base64
2.
PackageInfo info;
try {
info = getPackageManager().getPackageInfo("com.you.name", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md;
md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String something = new String(Base64.encode(md.digest(), 0));
//String something = new String(Base64.encodeBytes(md.digest()));
Log.e("hash key", something);
}
} catch (NameNotFoundException e1) {
Log.e("name not found", e1.toString());
} catch (NoSuchAlgorithmException e) {
Log.e("no such an algorithm", e.toString());
} catch (Exception e) {
Log.e("exception", e.toString());
}
And I have the key hash like this :
6R5************hZZbeBU=
the last char is '=' I write all of chars to the facebook app settings,
And I write my APP_ID to my android project.
What is the problem : The problem which I see on the all of my projects , is the same.
problem is I connect facebook with my account which the creator of the APP_ID .
I mean When I login with my account I connect yes I also post,see my friends , upload photo ,,,
but when I login to my app with different account I can t login.open just empty white page like this:
Actually I do not understand this and the more interesting thing is , when I download different android facebook projects I try them. And sure , I copy my app_id and again I connect facebook but different accounts I did not success to connect facebook.
What is the problem ? Should I do something on Facebook side like give permission or something else...
thanks,,,
You need to make your Facebook App Live from Sandbox mode.

Android Facebook Integration Error

I need a help. I am trying to integrate Facebook to my android app so that the users can log in using Facebook. The app runs perfectly on emulator but giving error on real devices. I am getting
Invalid android_key parameter. The key does not match any allowed key
Can Any one help me out to solve this problem?
Thanks in advance.
Just a shot in the dark.
Developers use to forget indicating the Android hash key in the developer settings of their FB account.
I think your problem is about hash key.
You may forgot to put android key hash in developer settings in your Facebook app. Or you may put a wrong one.
Check the below links that are related to the issue.
App is misconfigured for Facebook login: Android Facebook integration issue
https://developers.facebook.com/docs/android/getting-started/facebook-sdk-for-android/
I think hash key problem ,, use this code to get hash key...
private void getKeyHash() {
try {
PackageInfo info = SplashActivity.this.getPackageManager()
.getPackageInfo(SplashActivity.this.getPackageName(),
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Logger.e("KeyHash:",
Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}

Android Facebook Key Hash Stopped Working

I am creating an Android app that will integrate with Facebook. I have been able to successfully generate a Key Hash, and when I run my app to log in, I successfully got to the accept permissions button. I clicked accept and since then, I haven't been able to log back in from the app. I am given the error "(insert the key has i'm using here) does not match any allowed key. Configure your app key hashes at (lists my Facebook developer URL)". Is there any reason why a Key Hash would work and then would just stop? I did not alter any facebook settings and did not alter any application code. I've tried creating a new key hash, but that still didn't work. Any ideas on what this could be, or how to resolve it would be greatly appreciated!
I figured this out. Somehow, the Hash Key just stopped matching what I had inserted on the Facebook side. Using the facebook documentation, I added in code in my onCreate method that told me what the hash key was in my LogCat. I also added in some logging code for my catch exceptions in the event that I was screwing up my package name. This is the code:
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.your.package",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
Log.d("Error1", "NameNotFoundException");
} catch (NoSuchAlgorithmException e) {
Log.d("Error2", "Algorthim");
}
After I added that and ran it, I found the hash key in my log cat, and then just copied that to my Facebook App. Saved it, ran the app again and it worked!

Facebook error : allow key: configure your app key hashes at dev.facebook android [duplicate]

This question already has answers here:
This app has no Android Key hashes configured. - Login with Facebook SDK
(5 answers)
Closed 7 years ago.
When i run my facebook apps i get the following error. allow key. Configure your app key hashes at http://developers.facebook.com/apps/178779105632639 ...
Any idea?
It seems that hashkey you generated is not correct. You can generate app hash key from the following code. Try it
public static void showHashKey(Context context) {
try {
PackageInfo info = context.getPackageManager().getPackageInfo(
"com.example.project", PackageManager.GET_SIGNATURES); //Your package name here
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.v("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
}
1.It will Help you.Working fine link
2.while creating app, in developer site using some keyhash generated by your cmd prompt,use that KeyHash copy and paste
in developer Settings Page keyhash Column.
3.change the Single sign on toggle button-YES
You need to generate a hash key for your application and register that to the FB Developers console where you have created the application. I have written a blog for the same. You can find it out at :
http://www.solutionanalysts.com/blog/android-generate-key-hash-facebook
Hope this helps you.

Categories

Resources