从我的应用中退出Google

时间:2016-03-24 11:56:02

标签: java android android-studio google-login

我已经提出了一个应用程序,要求用户在访问我的应用程序之前登录他们的Google帐户。但是,我不知道用户如何从我的应用中退出他们的Google帐户。任何人都可以指出我正确的方向。感谢

我的代码暂时无法使用Google登录我的应用

public class Menu extends AppCompatActivity {
    private MobileServiceClient mClient;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_menu);

        try {
            mClient = new MobileServiceClient(
                    "https://craigsapp.azure-mobile.net/",
                    "BTkcgnFQvevAdmmRteHCmhHPzdGydq84",
                    this
            );
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        authenticate();
    }
    private void authenticate() {
        mClient.login(MobileServiceAuthenticationProvider.Google, new UserAuthenticationCallback() {

            @Override
            public void onCompleted(MobileServiceUser user, Exception exception, ServiceFilterResponse response) {
                if (exception == null) {
                    Log.w("TodoActivity", "Logged in");

                } else {
                    Log.e("TodoActivity", "They aren't logged in");
                }
            }
        });
    }
    }

1 个答案:

答案 0 :(得分:1)

mClient上应该有简单的private void Completed(object sender, AsyncCompletedEventArgs e) { if(e.Cancelled) MessageBox.Show("Download cancelled!"); else MessageBox.Show("Download completed!"); } 函数。我假设您使用了Azure Mobile services

所以只需创建一个按钮,用它分配onclick,它将调用此函数,它应该可以工作。