【问题标题】:Twitter Digits check if the authentication was already madeTwitter Digits 检查是否已经进行了身份验证
【发布时间】:2015-02-15 02:40:45
【问题描述】:

我设法整合了 twitter 数字并且身份验证工作正常,但我想检查用户是否已经添加了他的数字和代码。

目前我只有认证部分:

    final TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    Fabric.with(this, new Crashlytics(), new Twitter(authConfig));

还有按钮事件:

  digitsButton = (DigitsAuthButton) findViewById(R.id.auth_button);
    digitsButton.setCallback(new AuthCallback() {
        @Override
        public void success(DigitsSession session,
                            String phoneNumber) {
            // Do something with the session
            Toast.makeText(WelcomeActivity.this,"Registration Successful",Toast.LENGTH_SHORT).show();
        }

        @Override
        public void failure(DigitsException exception) {
            // Do something on failure
            Toast.makeText(WelcomeActivity.this,"Registration Failed",Toast.LENGTH_SHORT).show();
        }
    });

-

我如何检查用户是否已经完成了这些步骤?

【问题讨论】:

    标签: java android twitter twitter-oauth


    【解决方案1】:

    您可以通过将数据存储在某处来保存身份验证成功的事实。 Storage Options

    使用 SharedPreferences 检查身份验证是否成功,您可以使用以下 isAuthenticated

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    boolean isAuthenticated = settings.getBoolean("ALREADY_AUTHENTICATED", false);
    

    要设置身份验证成功 (true),您可以将其放入回调的 success 方法

    // We need an Editor object to make preference changes.
    // All objects are from android.context.Context
    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    SharedPreferences.Editor editor = settings.edit();
    editor.putBoolean("ALREADY_AUTHENTICATED", true /** or false */);
    
    // Commit the edits!
    editor.commit();
    

    【讨论】:

    • 您如何识别 SIM 卡更改?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多