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 8033315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:39:41+00:00 2026-06-05T01:39:41+00:00

My Android application allows users to update their Facebook status from a Fragment. I’ve

  • 0

My Android application allows users to update their Facebook status from a Fragment. I’ve implemented the following AsyncTask so they can log in:

    public class updateFacebookTask extends AsyncTask<String, Void, Boolean> {
    protected Boolean doInBackground(final String... message) {
        Log.i(TAG, "Async UFT");

        myFResult = false;

            Looper.prepare();   

            if (loginAndPostToWall()) {
                Log.i(TAG, "loginAndPostToWall Returned: " + myFResult);

                myFResult = true;

            } else {
                Log.i(TAG, "loginAndPostToWall Returned: " + myFResult);

                myFResult = false;
            }


            //Looper.loop();


        return myFResult;
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();

        Log.i(TAG, "UFT - oPrE");

    }
    @Override
    protected void onPostExecute(Boolean myFResult) {
        super.onPostExecute(myFResult);

        if (myFResult) {
            Log.i(TAG, "UFT oPE - Success: " + myFResult);


        } else {
            Log.w(TAG, "UFT oPE - fail: " + myFResult);

        }
    }

The AsyncTask uses the method loginAndPostToWall() as below, Which implements a DialogListener as part of the Facebook sdk:

public boolean loginAndPostToWall() {

    myFResult = false;

    facebook.authorize(getActivity(), PERMISSIONS,
            Facebook.FORCE_DIALOG_AUTH, new DialogListener() {

                public void onComplete(Bundle values) {
                    Log.i(TAG, "LoginDialog Complete - Success");


                    myFResult = true;


                }

                public void onFacebookError(FacebookError error) {
                    Log.w(TAG,
                            "onFacebookError - Authentication with Facebook failed");


                    myFResult = false;

                }

                public void onError(DialogError error) {
                    Log.w(TAG,
                            "onError - Authentication with Facebook failed");
                    looper = false;
                    Log.i(TAG, "looper " + looper);

                    myFResult = false;

                }

                public void onCancel() {
                    Log.w(TAG,
                            "onCancel - Authentication with Facebook cancelled");


                    myFResult = false;

                }
            });


    return myFResult;
}

I have two problems that I really need help with please:

  1. LogInAndPostToWall immediately returns myFResult as false. What I want it to do is wait until the login by webView has returned onComplete (or an error) from the DialogListener. How can I get it to return myFResult at that point and not before?

  2. If I include Looper.loop(); onPostExecute is never called. If I don’t include Looper.prepare(); I get an error saying I can’t create a handler without it. Am I supposed to call quit() somewhere?

I’ve been stuck on this for two days (!) and have read many, many SO posts – I’ve tried using runnables and logging which threads everything is running on etc, but no joy.

Thanks in advance for saving me…

  • 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-05T01:39:43+00:00Added an answer on June 5, 2026 at 1:39 am

    loginAndPostToWall() should be executed on the UI thread, as it modifyes the UI. doInBackgorund() method got never executed on UI thread and you should NOT ever include Looper.prepare() or Looper.loop() code there.

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

Sidebar

Related Questions

My Android application allows users to read full articles from various blogs and share
I have an android application that allows users to upload images to their account.
I've to develop an android application that allows users to chat I want to
My application allows users to take photos with their devices camera app, which are
I have recently created an Android application that allows users to add shopping items
I have an Android application that allows the user to connect to his Facebook
I've developed a desktop application that allows the user to extract images from their
My android application has several warnings of the following form when I run it
I would like to install an APK from within an Android application. Can anyone
I have a drawing application in Android that allows the user to draw with

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.