Facebook logout code in Android Java

Following Android java sample code is used to logout from facebook
floginlogout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(InsertpostActivity.this); // Setting Dialog Title alertDialog.setTitle("Confirm Delete..."); // Setting Dialog Message alertDialog.setMessage("Are you sure you want logout?"); // Setting Icon to Dialog alertDialog.setIcon(R.drawable.delete); // Setting Positive "Yes" Button alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to invoke YES event LoginManager.getInstance().logOut(); //moveTaskToBack(true); //finish(); Intent intent1 = new Intent(getApplicationContext(), MainActivity.class); intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); intent1.putExtra("currentpage", 1); startActivity(intent1); } }); // Setting Negative "NO" Button alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to invoke NO event //Toast.makeText(getApplicationContext(), "You clicked on NO", Toast.LENGTH_SHORT).show(); dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } });
Sign In or Register to comment.