Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在安卓系统中通过一个注销按钮实现Facebook和Google登录?_Android_Facebook_Login_Google Plus_Social - Fatal编程技术网

Android 如何在安卓系统中通过一个注销按钮实现Facebook和Google登录?

Android 如何在安卓系统中通过一个注销按钮实现Facebook和Google登录?,android,facebook,login,google-plus,social,Android,Facebook,Login,Google Plus,Social,Hello Friends我是android、Facebook和google plus的初学者,在android应用程序中使用单注销按钮登录当用户登录时,您可以存储一个值为“Facebook”或“google”的变量。单击“注销”按钮时,检查变量的值,然后根据该值执行任何需要的操作。首先使用下面关于用户欢迎活动的代码行初始化Facbook SDK FacebookSdk.sdkInitialize(getApplicationContext()); 然后,创建一个logoutUser方法,该方

Hello Friends我是android、Facebook和google plus的初学者,在android应用程序中使用单注销按钮登录

当用户登录时,您可以存储一个值为“Facebook”或“google”的变量。单击“注销”按钮时,检查变量的值,然后根据该值执行任何需要的操作。

首先使用下面关于用户欢迎活动的代码行初始化Facbook SDK

FacebookSdk.sdkInitialize(getApplicationContext());
然后,创建一个logoutUser方法,该方法应该在单击logout按钮时调用,如下所示

private void logoutUser() {
    LoginManager.getInstance().logOut(); // this is to logout Facebook

    Intent intent = new Intent(this, LoginActivity.class);
    intent.putExtra("finish", true); // if you are checking for this in your other Activities
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
            Intent.FLAG_ACTIVITY_CLEAR_TASK |
            Intent.FLAG_ACTIVITY_NEW_TASK |
            Intent.FLAG_ACTIVITY_NO_ANIMATION |
            Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    startActivity(intent);
    finish(); // This will kill all current logged in activities
}

通过单击Listner上的一个注销按钮调用这个方法

你有密码吗?我是android初学者,我不知道怎么做,请附加