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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:31:36+00:00 2026-06-12T04:31:36+00:00

I am trying to show a toast when click on a button that button

  • 0

I am trying to show a toast when click on a button that button request’s a listener. I am logging out through this button and i want to show toast on loggout completion so i put toast in onComplete method of request Listener. Here is my complete code

HomeActivity which contains button listeners

public class HomeActivity extends Activity implements OnClickListener{
private static final String TAG = "Facebook";
private Button mLogin, mLogout, mShare;
private Facebook facebook;
private AsyncFacebookRunner abRunner;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.activity_home);

    //mLogin.setBackgroundColor(Color.BLUE);
    // Initialize facebook objects
    facebook = new Facebook("479652662068145");
    abRunner = new AsyncFacebookRunner(facebook);

    // Setup VIews
    mLogin= (Button) findViewById(R.id.Login);
    mLogout= (Button) findViewById(R.id.Logout);

    mLogin.setOnClickListener(this);
    mLogout.setOnClickListener(this);

}
@Override
public void onClick(View v){

   int id = v.getId();
   switch(id){
   case R.id.Login:
       FacebookLoginDialog login = new FacebookLoginDialog();
       facebook.authorize(this, login);
        break;
   case R.id.Logout:
       FacebookLogoutRequest logout = new FacebookLogoutRequest(this);
       abRunner.logout(this, logout);
       break;
        default:
            break;

   }
 }


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_home, menu);
    return true;
 }



 }

And my RequestListener Code

public class FacebookLogoutRequest implements RequestListener{

private Context context;

public FacebookLogoutRequest (Context context){

this.context= context;
 }
public void onComplete(String response, Object state) {

Toast toast = Toast.makeText(context, "You Are Logged Out", Toast.LENGTH_SHORT);
toast.show();
}

@Override
public void onIOException(IOException e, Object state) {
    // TODO Auto-generated method stub

}

@Override
public void onFileNotFoundException(FileNotFoundException e, Object state) {
    // TODO Auto-generated method stub

}

@Override
public void onMalformedURLException(MalformedURLException e, Object state) {
    // TODO Auto-generated method stub

}

@Override
public void onFacebookError(FacebookError e, Object state) {
    // TODO Auto-generated method stub

}


 }

Please Help I am stuck here..Thanks

  • 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-12T04:31:37+00:00Added an answer on June 12, 2026 at 4:31 am

    Use Activity instead of Context because context is not for UI reference

    public class FacebookLogoutRequest implements RequestListener{
    
        private Activity context;
    
        public FacebookLogoutRequest (Activity context){
    
        this.context= context;
         }
        public void onComplete(String response, Object state) {
    
        Toast toast = Toast.makeText(context, "You Are Logged Out", Toast.LENGTH_SHORT);
        toast.show();
        }
    
        @Override
        public void onIOException(IOException e, Object state) {
            // TODO Auto-generated method stub
    
        }
    
        @Override
        public void onFileNotFoundException(FileNotFoundException e, Object state) {
            // TODO Auto-generated method stub
    
        }
    
        @Override
        public void onMalformedURLException(MalformedURLException e, Object state) {
            // TODO Auto-generated method stub
    
        }
    
        @Override
        public void onFacebookError(FacebookError e, Object state) {
            // TODO Auto-generated method stub
    
        }
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to show a Toast Message when user click on a Button inside
I'm currently trying to add a click listener to the menu hardware button. Currently
I'm trying to move button (with animation) upon click. I want it to move
When trying you get the activity to change on the click of a button,
I'm trying to create an AlertDialog that opens when an item is click in
I am trying to retrieve my current location on the button click in an
So I'm trying to write an activity that has two spinners and a button,
ok so im trying capture the webview on button click, of the web page
I am trying to create a listview that when you click on an entry
I'm trying to make it so that once the user click on an item

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.