Android log in app using Facebook

Zodiac

Please anyone can tell me why this code do not return the result? It always stops in

( if is.open()) 

and gives false.

com.facebook.Session.openActiveSession(this, true, new com.facebook.Session.StatusCallback() {

            @Override
            public void call(com.facebook.Session session, SessionState state,
                    Exception exception) {
                // TODO Auto-generated method stub
                if (session.isOpened()) {

                      // make request to the /me API
                      Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {

                        // callback after Graph API response with user object
                        @Override
                        public void onCompleted(GraphUser user, Response response) {
                          if (user != null) {
                            TextView welcome = (TextView) findViewById(com.example.connectwithfacebook.R.id.textView1);
                            welcome.setText("Hello " + user.getName() + "!");
                          }
                        }
                      });
                    }
            }
            });     

I implemented another way but I had then the same problem too.

ObieMD5

It has to do with your hashkey within facebook. Run this code (make sure to change package name in 3rd line):

    try {
        PackageInfo info = getPackageManager().getPackageInfo(
                "your.root.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) {

    } catch (NoSuchAlgorithmException e) {

    }

It will output the signature as "KeyHash:XXXXX" into logcat. Copy and paste that key into facebook and wil should start working.

Info from here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Java example of how to log in to Google App Engine with a Facebook account using OAuth

Android App Crashes on Facebook Sign in

Login with facebook into android app

Open Facebook Page in Facebook App (if installed) on Android

Login with facebook crash the app if using FaceBook Lite

how to implement Facebook sharing and then deep link that post using deep link(open my app) in android App?

Log in to facebook using selenium in Java

Can't log on to Azure App Service using Facebook access token

Error while using facebook app invite for android

Facebook in-app events log for IOS

facebook login android app crashes

Hashkey mismatch android facebook app

unity Facebook log in issue android

Facebook Group chat in Android App

add option to login using twitter, facebook and google using socialauth on android app

Apps are updating status via facebook android sdk 3.17 but not when using Facebook's official app (#404)

Android App for Facebook

Facebook authentication via android app

Android app crashes with Facebook Login

Write Facebook Comment in Android App

Log in with facebook in Android app withount the need of the facebook app

Open link with facebook app in android

Facebook Checkin from Android App

Using facebook login in android app(no errors in logcat)

Login to my app using facebook : error when using Facebook App

Android : How to send app invite message using whatsapp,facebook,gmail,etc from my app

android:google login api and facebook log in api cannot use in app apk

Change Facebook Account / log out completely using Firebase and Android

crashes app when I log in using facebook auth