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

  • Home
  • SEARCH
  • 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 8763255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:44:25+00:00 2026-06-13T15:44:25+00:00

I have created an application which needs sign in from Facebook/Twitter/Google to get started.

  • 0

I have created an application which needs sign in from Facebook/Twitter/Google to get started. In a layout I have created three switches each for Facebook, Twitter and Google which has options ON and OFF. I want to make the switch of the particular account as ‘ON’ if the user is logged in from that corresponding account. Example if the user is logged in from Facebook, only the switch beside Facebook should be ON. How can I do that?

Any suggestions would be appreciated, and also if somebody know then please refer me to any tutorial related to this.
Below is my code for the login page. I have shown the login for Facebook part:
Thanx 🙂

private OnClickListener loginButtonListener = new OnClickListener() {
        @SuppressWarnings("deprecation")
        public void onClick( View v ) {
            String[] permissions = { "offline_access", "publish_stream", "user_photos", "publish_checkins","photo_upload" };


            if(v.getId() == R.id.button1 )
            {
                facebookSwitch = true;
                twitterSwitch = false;
                googleSwitch = false;
                if( !mFacebook.isSessionValid() ) {
                    Toast.makeText(Login.this, "Authorizing", Toast.LENGTH_SHORT).show();
                    mFacebook.authorize(Login.this, permissions, new LoginDialogListener());
                }
                else {
                    Toast.makeText( Login.this, "Has valid session", Toast.LENGTH_SHORT).show();
                    try {
                        JSONObject json = Util.parseJson(mFacebook.request("me"));
                        //Log.d("Login", "11111111111111111");
                        String facebookID = json.getString("id");
                        //Log.d("Login", "22222222222222"); 

                        String firstName = json.getString("first_name");
                        //Log.d("Login", "3333333333333333333");

                        String lastName = json.getString("last_name");
                        //Log.d("Login", "4444444444444444444444");

                        Toast.makeText(Login.this, "You already have a valid session, " + firstName + " " + lastName + ". No need to re-authorize.", Toast.LENGTH_LONG).show();
                        Intent intent = new Intent(Login.this,MainActivity.class);
                        startActivity(intent);
                    }
                    catch( Exception error ) {
                        Toast.makeText( Login.this, error.toString(), Toast.LENGTH_SHORT).show();
                    }
                    catch( FacebookError error ) {
                        Toast.makeText( Login.this, error.toString(), Toast.LENGTH_SHORT).show();
                    }
                }
            }
  • 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-13T15:44:26+00:00Added an answer on June 13, 2026 at 3:44 pm

    Try it this way….

    – First create a Singleton Class with 3 booleanvariables for 3 logins info, and thereGetter-Setter`. Singleton is needed over here so that only One object of that class is formed no matter from where that class is called in the whole application. So now you have a single point of info.

    – Always check Singleton Class’s variables in the beginning of another Activity or when needed by you, to know that whether the user is logged into one or two or all the social networking sites.

    ////////////////////////////////Edited Part/////////////////////////////

    A simple way of creating a Singleton is below, thought there are few more:

    public class Test{
    
       public static Test uniqueInstance = new Test();
    
       private Test(){}
    
       public static Test getInstance(){
    
          return uniqueInstance;       
    
          // No matter what but always u will get the same instance.
    
       }
    
    }
    

    Now To call this object in another class do as below…

    public class Main{
    
     Test t = Test.getInstance();    // Now use t to call the fields and methods of class T.
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an application which needs to have a profile box tab which
i have created an application which show data from user current location. I want
I have created an application which needs 'hand-over' to the support group in the
We have created an application which we want to run in a 64 bit
I have created a desktop application which continuously changes the image on a fixed
I have created an IPAD application which supports on Portrait orientation. Before uploading on
I have successfully created an application which is workable on the >3.0 devices. However,
I have created an html5 application in which I open an pdf, after opening
I have created a wpf application into which I have added a user control
I am new to this iphone development.I have created a tab bar application which

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.