android - Strava Api 令牌 Android
问题描述
我已经用 Strava 授权了我的应用程序,我想从中获取我的令牌。问题是在这段代码中
LoginResult result = api.getTokenForApp(AppCredentials.with(29519, "8d55af50a97a9f4b5269670de00bf5e6f4b9942d "))
.withCode(code)
.execute();
我认为它永远不会运行,因为我看不到打印的 test5。它直接进入线程外的意图。另外,我如何从我的线程和我的类之外的 LoginResult 获取结果并使用它?
这是代码:
@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d("Strava code", "TEST1");
if(requestCode == RQ_LOGIN && resultCode == RESULT_OK && data != null) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
String code = data.getStringExtra(StravaLoginActivity.RESULT_CODE);
Log.d("Strava code", "TEST2");
AuthenticationConfig config = AuthenticationConfig.create()
.debug()
.build();
Log.d("Strava code", "TEST3");
AuthenticationAPI api = new AuthenticationAPI(config);
Log.d("Strava code", "TEST4");
LoginResult result = api.getTokenForApp(AppCredentials.with(29519, "8d55af50a97a9f4b5269670de00bf5e6f4b9942d "))
.withCode(code)
.execute();
Log.d("Strava code", "TEST5");
} catch (Exception e) {
e.printStackTrace();
}
}
});
thread.start();
Intent testInt= new Intent(MainActivity.this,TestActivity.class);
startActivity(testInt);
}
解决方案
推荐阅读
- ffmpeg - 如何通过 ffmpeg (C++) 获取 rtsp-sesson 的开始时间?start_time_realtime 始终等于 -9223372036854775808
- android - 如何将 LiveData 转换为 2 个 liveData?
- excel - 如何在 CATIA 上方获取 Excel-Userform 到前台
- css - 删除具有重复类名的 div
- bootstrap-modal - Wysihtml5 破坏模态
- angular - 在 require.context() 中使用模块路径时在 afterAll [object ErrorEvent] 中引发错误
- java - 如何只在字符串中保留不同类型的字母,例如:拉丁字母、片假名、西里尔字母
- c# - 如何避免实体框架与空/空数据库的连接
- javascript - 线程以代码 0 结束 - FileSystemWatcher?
- javascript - 为什么我的代码没有在 Alexa 开发控制台模拟器上运行 if 语句,即使我说出/键入插槽中存在的值?