Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8415409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:26:18+00:00 2026-06-10T01:26:18+00:00

I’m trying to use FB Connect on my app, and everything works fine in

  • 0

I’m trying to use FB Connect on my app, and everything works fine in the emulator and debugging in a Galaxy Nexus, but after uploading it to google play it stops working.

If I install the app downloading it from Play, my facebook.authorize function returns a DialogError (I just don’t know what error because I’m only able to view logcat when the installation is made with eclipse). And it only happens if I have the facebook app installed. So when I uninstall the fb app it works nice…

Maybe is some wrong configuration I’ve made while preparing facebook SDK on my computer? I pasted all my code below, but don’t have any log…

public class FacebookConnectActivity extends Activity {
private static final String TAG_JSON = "json";
static Facebook facebook = new Facebook("11111111111111");
AsyncFacebookRunner mAsyncRunner;
private static SharedPreferences mPrefs;
JSONObject json = null;
Context ctx = this;
boolean callback = false;
private static Context staticContext;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.resgatar_produto_layout);
    FacebookConnectActivity.staticContext = getApplicationContext();
    Log.e("FacebookConnect", "Activity Started");

    mPrefs = getSharedPreferences("PREFS_LOGIN", MODE_PRIVATE);
    String access_token = mPrefs.getString("access_token", null);
    long expires = mPrefs.getLong("access_expires", 0);
    if (access_token != null) {
        facebook.setAccessToken(access_token);
        Log.e("FacebookConnect",
                "Access Token retrieved from SharedPreferences");
    }
    if (expires != 0) {
        facebook.setAccessExpires(expires);
        Log.e("FacebookConnect",
                "Access Expires retrieved from SharedPreferences");
    }

    if (!facebook.isSessionValid()) {
        facebook.authorize(this, new String[] { "email", "user_photos",
                "user_birthday", "user_hometown", "user_relationships",
                "user_location", "user_work_history", "publish_actions" },
                new DialogListener() {
                    @Override
                    public void onComplete(Bundle values) {
                        Log.e("FacebookConnect", "User authorized");
                        Log.e("FacebookConnect",
                                "onComplete called at facebook.authorize");
                        Log.e("FacebookConnect", "Access Token: "
                                + facebook.getAccessToken().toString());
                        try {
                            mAsyncRunner = new AsyncFacebookRunner(facebook);
                            mAsyncRunner.request("me",
                                    new SampleRequestListener());
                            Log.e("FacebookConnect",
                                    "AsyncFacebookRunner request started (facebook.authorize.onComplete)");
                            Bundle params = new Bundle();
                            params.putString("link",
                                    "https://apps.facebook.com/qranio_game/");
                            params.putString("picture", "http://www.qranio.com/site/images/logo_qranio_facebook.png");
                            int count = 0;
                            while (json == null && count<20){
                                Log.e("FacebookConnect",
                                        "Waiting for json (facebook.authorize.onComplete)");
                                waiting(1000);
                                count++;
                            }
                            if (!(count<20)){
                                noConnectionAlert();
                            }
                            String usuario = json.getString("first_name");
                            params.putString("name", usuario+" está jogando Qranio para Android");
                            params.putString("caption", "Qranio - Making Learning Fun");
                            params.putString("description", "O Qranio é uma plataforma online que propicia o Saber. Você joga, " +
                                    "aprende, acumula Qi$ e troca por prêmios incríveis! Venha jogar também!");
                            //JSONArray fbArr = new JSONArray("{\"name\":\"Jogar\",\"link\":\"https://apps.facebook.com/qranio_game/\"}");
                            params.putString("actions", "{\"name\":\"Jogar\",\"link\":\"https://apps.facebook.com/qranio_game/\"}");
                            params.putString("display", "touch");
                            facebook.dialog(ctx, "feed", params,
                                    new SampleDialogListener());
                            Log.e("FacebookConnect",
                                    "Post on Wall Dialog called (facebook.authorize.onComplete)");

                            // facebook.
                            // if (facebook.isSessionValid()){

                            // }else{
                            // Log.e("FacebookConnect",
                            // "Invalid facebook session while trying to fetch user data");
                            // }

                        } catch (FacebookError fbe) {
                            Log.e("FacebookConnect",
                                    "facebook.authorize FacebookError "
                                            + fbe.toString());

                        } catch (Exception e) {
                            Log.e("FacebookConnect",
                                    "facebook.authorize Exception "
                                            + e.toString());
                        }
                    }

                    @Override
                    public void onFacebookError(FacebookError error) {
                        Log.e("FacebookConnect",
                                "FacebookError authorizing: "
                                        + error.toString());
                        final AlertDialog alertDialog = new AlertDialog.Builder(
                                FacebookConnectActivity.this).create();
                        alertDialog.setTitle("Erro");
                        alertDialog
                                .setMessage("Ocorreu um erro com o Facebook, por favor tente novamente.");
                        alertDialog.setButton("OK",
                                new DialogInterface.OnClickListener() {
                                    public void onClick(
                                            DialogInterface dialog,
                                            int which) {
                                        alertDialog.dismiss();
                                        finish();
                                    }
                                });
                        alertDialog.show();
                    }

                    @Override
                    public void onError(DialogError e) {
//Here is where I'm getting the error when downloaded from Play
                        Log.e("FacebookConnect",
                                "Error authorizing: " + e.toString());
                        final AlertDialog alertDialog = new AlertDialog.Builder(
                                FacebookConnectActivity.this).create();
                        alertDialog.setTitle("Erro");
                        alertDialog
                                .setMessage("Erro ao tentar conectar com o facebook, tente novamente.");
                        alertDialog.setButton("OK",
                                new DialogInterface.OnClickListener() {
                                    public void onClick(
                                            DialogInterface dialog,
                                            int which) {
                                        alertDialog.dismiss();
                                        finish();
                                    }
                                });
                        alertDialog.show();
                    }

                    @Override
                    public void onCancel() {
                        Log.e("FacebookConnect", "Autorizing canceled");
                        finish();
                    }
                });

    } else {
        mAsyncRunner = new AsyncFacebookRunner(facebook);
        mAsyncRunner.request("me", new SampleRequestListener());
        Log.e("FacebookConnect",
                "Valid session found, AsyncFacebookRunner request started");

        startDataProcess();
    }

}

public void noConnectionAlert(){
    final AlertDialog alertDialog = new AlertDialog.Builder(
            FacebookConnectActivity.this).create();
    alertDialog.setTitle("Erro");
    alertDialog
            .setMessage("Verifique sua conexão com a internet e tente novamente.");
    alertDialog.setButton("OK",
            new DialogInterface.OnClickListener() {
                public void onClick(
                        DialogInterface dialog,
                        int which) {
                    alertDialog.dismiss();
                    finish();
                }
            });
    alertDialog.show();
}

public static void waiting (int n){

    long t0, t1;

    t0 =  System.currentTimeMillis();

    do{
        t1 = System.currentTimeMillis();
    }
    while (t1 - t0 < n);
}

public static void logoutFB() {
    if (facebook.isSessionValid()) {
        Log.e("AndroidDashboarDesign",
                "Valid FB session found, logging out");
        AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
        mAsyncRunner.logout(staticContext, new BaseRequestListener() {
            @Override
            public void onComplete(String response, Object state) {
                Log.e("AndroidDashboarDesign", "Complete FB logout");
            }

            @Override
            public void onIOException(IOException e, Object state) {
                Log.e("AndroidDashboarDesign",
                        "(logout) IOException: " + e.getMessage());
            }

            @Override
            public void onFileNotFoundException(FileNotFoundException e,
                    Object state) {
                Log.e("AndroidDashboarDesign",
                        "(logout) FileNotFoundException: " + e.getMessage());
            }

            @Override
            public void onMalformedURLException(MalformedURLException e,
                    Object state) {
                Log.e("AndroidDashboarDesign",
                        "(logout) MalFormedURLException: " + e.getMessage());
            }

            @Override
            public void onFacebookError(FacebookError e, Object state) {
                Log.e("AndroidDashboarDesign", "(logout) FacebookError: "
                        + e.getMessage());
            }
        });
    }
}

public void startDataProcess() {
    int count = 0;
    while (json == null && count<20){
        Log.e("FacebookConnect",
                "Waiting for json (Valid session found)");
        waiting(1000);
        count++;
    }
    if (!(count<20)){
        noConnectionAlert();

    }else{
    SharedPreferences.Editor editor = mPrefs.edit();
    editor.putString("access_token", facebook.getAccessToken());
    editor.putLong("access_expires", facebook.getAccessExpires());
    editor.commit();

    Log.e("FacebookConnect", "startDataProcess() executed");
    Intent a = new Intent(FacebookConnectActivity.this,
            FacebookDataProcess.class);
    a.putExtra(TAG_JSON, json.toString());
    startActivity(a);
    finish();
    }
}

public class SampleDialogListener extends BaseDialogListener {

    public void onComplete(Bundle values) {
        Log.e("FacebookConnect", "SampleDialogListener complete");
        final String postId = values.getString("post_id");
        if (postId != null) {
            Log.e("FacebookConnect",
                    "(SampleDialogListener) Dialog Success! post_id="
                            + postId);
            //mAsyncRunner.request(postId, new WallPostRequestListener());
            //Log.e("FacebookConnect", "WallPostRequestListener started");
            Toast.makeText(FacebookConnectActivity.this, "Mensagem postada com sucesso!", Toast.LENGTH_LONG).show();
            startDataProcess();
        } else {
            Log.e("FacebookConnect",
                    "(SampleDialogListener) No wall post made, maybe canceled by user."); // Usuario
                                                                                            // clicou
                                                                                            // em
                                                                                            // Cancelar
            startDataProcess();
        }
    }

    public void onError(DialogError e) {
        Log.e("FacebookConnect",
                "Error authorizing: " + e.toString());
        final AlertDialog alertDialog = new AlertDialog.Builder(
                FacebookConnectActivity.this).create();
        alertDialog.setTitle("Erro");
        alertDialog
                .setMessage("Erro ao tentar conectar com o facebook, não foi possível publicar em seu mural.");
        alertDialog.setButton("OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(
                            DialogInterface dialog,
                            int which) {
                        startDataProcess();
                        alertDialog.dismiss();
                    }
                });
        alertDialog.show();
    }

    public void onCancel() { // Usuario clicou no X do dialog
        Log.e("FacebookConnect", "Post to Wall Canceled with \"X\" button");
        startDataProcess();
    }
}

public class WallPostRequestListener extends BaseRequestListener {

    public void onComplete(final String response, final Object state) {
        Log.e("FacebookConnect", "WallPostRequestListener complete");
        Log.e("FacebookConnect", "(WallPostRequestListener) Got response: "
                + response);
        String message = "<empty>";
        try {
            JSONObject json = Util.parseJson(response);
            message = json.getString("message");
        } catch (JSONException e) {
            Log.e("FacebookConnect",
                    "(WallPostRequestListener) JSON Error in response: "
                            + e.toString());
        } catch (FacebookError e) {
            Log.e("FacebookConnect",
                    "(WallPostRequestListener) Facebook Error: "
                            + e.getMessage());
            // Toast.makeText(ctx, "Erro ao postar no Facebook.",
            // Toast.LENGTH_LONG).show();
        }
        startDataProcess();
    }
}

public class SampleRequestListener extends BaseRequestListener {

    public void onComplete(final String response, final Object state) {
        try {

            // process the response here: executed in background thread
            Log.e("FacebookConnect", "SampleRequestListener complete");
            Log.e("SampleRequestListener",
                    "Response: " + response.toString());
            json = Util.parseJson(response);
            Log.e("FacebookConnect", "JSON: " + json.toString());

            // postOnWall();
            // startDataProcess();

            // then post the processed result back to the UI thread
            // if we do not do this, an runtime exception will be generated
            // e.g. "CalledFromWrongThreadException: Only the original
            // thread that created a view hierarchy can touch its views."

        } catch (JSONException e) {
            Log.e("FacebookConnect",
                    "JSON Error in response (SampleRequestListener): "
                            + e.getMessage());
        } catch (FacebookError e) {
            Log.e("FacebookConnect",
                    "Facebook Error at SampleRequestListener: "
                            + e.getMessage());
        }

    }
}

public void postOnWall() {
    Looper.prepare();
    Bundle params = new Bundle();
    params.putString("link", "www.qranio.com");
    facebook.dialog(ctx, "feed", params, new SampleDialogListener());
    Log.e("FacebookConnect", "SampleDialogListener started");
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    facebook.authorizeCallback(requestCode, resultCode, data);
    callback = true;
    Log.e("FacebookConnect",
            "Authentication authorizeCallback called (onActivityResult)");

}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:26:21+00:00Added an answer on June 10, 2026 at 1:26 am

    You used a different keystore file when you signed your application for distribution.

    To fix this, run the same command but change the alias and the location of the keystore to the keystore file that you used for distribution

    keytool -exportcert -alias YOUR_ALIAS_HERE -keystore ~/path/to/yourapp.keystore | openssl sha1 -binary | openssl base64

    and paste the resulting string into your Facebook app’s dashboard settings under the Android Key Hash section.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am confused How to use looping for Json response Array in another Array.
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.