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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:43:11+00:00 2026-06-05T10:43:11+00:00

I want my application to use fb login(this is optional). So first I’m launching

  • 0

I want my application to use fb login(this is optional). So first I’m launching my base activity and then fb activity as a child activity. I want that when a user presses back button it should return to its parent activity. For the facebook activity, the contentview is not set, it’s just a blank screen. I’m facing the following problem.

  1. When the fb activity is launched & I press back, a blank screen shows up which probably(I’m not sure) is the content view which I have not set. I want it to direct to parent activity & not to this blank screen.

Following are the codes:

Parent Activity(Launcher)

public class AccountSettingsActivity extends Activity {
    /** Called when the activity is first created. */
        Button registerButton;
        Button fbButton;

        AccountSettingsActivity ob ;
        final Context cont = this;
    @Override
    public void onCreate(Bundle savedInstanceState) {   
        super.onCreate(savedInstanceState);
        setContentView(R.layout.account);
        Log.i ("Location_settings", "In Account Settings Class");

        registerButton = (Button)this.findViewById(R.id.registerbutton);
        fbButton = (Button)this.findViewById(R.id.fbbutton);

        registerButton.setVisibility(1);

        //Toast.makeText(cont, "In Accounts Settings", Toast.LENGTH_LONG);


        fbButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {               
                 Log.i("Account-Settings","fb Button clicked");
                 Intent fb = new Intent(AccountSettingsActivity.this,facebookMain.class);
                 fb.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                 startActivityForResult(fb,0);

            }
        });

        registerButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {               
                 Log.i("Account-Settings","Register Button clicked");
                 ProgressDialog dialog = ProgressDialog.show(AccountSettingsActivity.this, "Syncing with server", "Please wait...", true);
                 new initialsync(dialog).execute("");            

            }
        });

        fbButton.performClick();

    }

}

Child activity(facebook)

public class facebookMain extends Activity {

    String abc;
    Facebook facebook = new Facebook("1234567890");
    private SharedPreferences mPrefs;
        private Bundle parameters;
        facebookMain ob;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /*
         * Get existing access_token if any
         */


        mPrefs = getPreferences(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);
        }
        if(expires != 0) {
            facebook.setAccessExpires(expires);
        }

        /*
         * Only call authorize if the access_token has expired.
         */
        if(!facebook.isSessionValid()) {

            facebook.authorize(this, new String[] { "read_friendlists", "read_mailbox", "email" }, new DialogListener() {
                @Override
                public void onComplete(Bundle values) {
                    SharedPreferences.Editor editor = mPrefs.edit();
                    editor.putString("access_token", facebook.getAccessToken());

                    abc = facebook.getAccessToken();


                    editor.putLong("access_expires", facebook.getAccessExpires());
                    editor.commit();

                    Intent intent=new Intent();     
                    intent.putExtra("access token",abc);
                    setResult(RESULT_OK, intent);
                    finish();
                }

                @Override
                public void onFacebookError(FacebookError error) {}


                @Override
                public void onCancel() {
                finish();
                }

                @Override
                public void onError(DialogError e) {
                        // TODO Auto-generated method stub

                }
            });
        }

        if(facebook.isSessionValid())
        {
            SharedPreferences shared = mPrefs;

            abc = shared.getString("access_token", "");

            Intent intent=new Intent();     
            intent.putExtra("access_token",abc);
            setResult(RESULT_OK, intent);
            Toast.makeText(ob,"facebook session valid", Toast.LENGTH_SHORT);
            finish();
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        facebook.authorizeCallback(requestCode, resultCode, data);

        AppLog.logger("facebookmain, Back key pressed");
                    Intent intent=new Intent();     
                    intent.putExtra("abc",abc);
                    setResult(RESULT_OK, intent);
                    finish();
    }
}

any help????

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

    There are few possibilities after viewing your code. As FB is very straight forward but I dont know why you are doing this. According to your code…

    • You are not handling if the session is valid. So finish the activity if the session is valid.
    • You should handle all events in Listener.
    • You should not create new intent in your onActivityResult, use the intent which is passed in that function.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want a facility that if user login then goes to home/index i not
I am building a DLL that another application would use. I want to store
I want to develop an application that will use mathematical programming to solve lp
I use this link to put the login links on my application : https://github.com/plataformatec/devise/wiki/How-To:-Add-sign_in,-sign_out,-and-sign_up-links-to-your-layout-template
I want to Unit Test my application which use MSMQ but i found no
i have application who use specific process during running and i want to sample
In my android application I use camera to capture photo. I want to print
I want to start an application which will use ajax push, however the web
1) I use Visual Studio 2008 (C#) 2) I want my desktop application to
I want to write a web application and want to use Ruby. I have

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.