0

Hello this is the code and it does retrieve user info but when I turn it into an apk it doesnt retrieve any user info.Please help:

GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(),
                    new GraphRequest.GraphJSONObjectCallback()
                    {
                        @Override
                        public void onCompleted(JSONObject object, GraphResponse response)
                        {
                            Log.i("LetsMeetFragment" + response.toString());

// imageURL = new URL("https://graph.facebook.com/" + userID + "/picture?width=" + width +"&height=" + height); // InputStream inputStream = (InputStream) imageURL.getContent(); // bitmap = getCroppedBitmap(BitmapFactory.decodeStream(inputStream));

                            try
                            {
                                String userID = (String) object.get("id");
                                letsMeetFlow.getUserUpdateRequestObj().setFb_id(userID);
                                BService.setFacebookID(userID);BService.setFacebookConnected(true);
                                PreferenceConnector.writeString(getContext(),ApplicationConstants.FacebookID, userID);


                                String userName = (String) object.get("name");
                                String DOB = (String) object.get("birthday");
                                String Gender = (String) object.get("gender");


                                if (Gender.equalsIgnoreCase("male"))
                                {
                                    manSeletion();
                                }
                                setBODField(DOB);

                                String[] userNamearray = userName.split(" ");
                                if (userNamearray.length > 1)
                                {
                                    String tmpName = "";
                                    for (int i = 0; i < userNamearray.length - 1; i++)
                                    {
                                        tmpName += userNamearray[i] + " ";
                                    }
                                    NameField.setText(tmpName.trim());
                                    LastNameField.setText(userNamearray[userNamearray
                                            .length - 1].trim());

                                }
mrehan
  • 1,122
  • 9
  • 18
Ali Yılmaz
  • 93
  • 3
  • 12

1 Answers1

0

For what i could understand, your code works when you are in debug mode, but when you try to compile a signed apk stops working.

This could be the signature hash, you have the signature hash of your debug key on facebook, but when you compile with your key the hash changes

You can do several things to retrive the hash of your key one is this

public void printKeyHash() {
    try {
        PackageInfo info = getPackageManager().getPackageInfo("com.your.package.name.don't.forget.to.chang.this", PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.e("SHA: ", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
}

tun this code at startup and check your logs for the hash, it will print a read text something like SHA: xxxxYourHashxxxxx

Copy paste this hash and update the one you have on facebook.

Tiago Oliveira
  • 1,582
  • 1
  • 16
  • 31