如何从strava API获取运动员数据和行程?

时间:2018-10-22 09:46:45

标签: android api strava

我想知道如何从strava到我的android应用中检索用户数据。我有此代码

ExampleAuthActivity.java

public class ExampleAuthActivity extends StravaAuthenticateActivity {

    /*****************************************
     * Methods override START
     */

    /**
     * Client ID
     */
    protected String getStravaClientId() {
        return "29519";
    }

    /**
     * Client Secret
     */
    protected String getStravaClientSecret() {
        return "8d55af50a97a9f4b5269670de00bf5e6f4b9942d";
    }

    /**
     * Scopes to auth for
     * (default public)
     */
    protected Collection<String> getStravaScopes() {
        return Arrays.asList(StravaScopes.SCOPE_PUBLIC);
    }

    /**
     * Should we use the local cache?
     * (default true)
     */
    protected boolean getStravaUseCache() {
        return true;
    }

    /**
     * Should we check a token (against Strava's API) or should we just assume it's good?
     * (default true)
     */
    protected boolean getStravaCheckToken() {
        return true;
    }

    /**
     * What intent should we kick off, given OK auth
     */
    protected Intent getStravaActivityIntent() {
        return new Intent(this, ExampleMainActivity.class);
    }

    /**
     * Should we finish this activity after successful auth + kicking off next activity?
     * (default true)
     */
    protected boolean getStravaFinishOnComplete() {
        return true;
    }

    /**
     * Methods override END
     ****************************************/
}

ExampleMainActivity.java

public class ExampleMainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView tv = (TextView) findViewById(R.id.tv_access_token);

        // Here's how you get the access token passed to the view:
        String accessToken = StravaAuthenticateActivity.getStravaAccessToken(this);
        String text = "Access Token:\n\n" + accessToken;
        tv.setText(text);

    }
}

当我按下“ connect with strava”按钮时,它会给我这样的访问令牌enter image description here

现在我想知道的是如何访问和获取用户数据(例如名称,km等)并将其显示在我的应用程序中?我试图阅读Stravas文档,但我听不懂。 / p>

0 个答案:

没有答案