在Android的Fitbit账户整合 [英] Fitbit account Integration in Android
问题描述
我工作的这是关系到医学科学的应用程序。 当我要实现FITBIT设备与我的应用程序。 我下面的这fitbit开发工具,但我无法融入它,如果我做手工,而不fitbit库我 我无法验证后,回到我的应用程序。我的code是 下面 -
I am working on an application which is related to medical science. Where I have to implement FITBIT device with my application. I am following fitbit developer tools for it but I am unable to integrate it and if I am doing it manually without fitbit library I am unable to back on my application after authentication. my code is below-
private void login() {
try {
HttpResponse response = null;
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 20000);
HttpConnectionParams.setSoTimeout(httpParameters, 20000);
HttpClient client = new DefaultHttpClient(httpParameters);
HttpGet request = new HttpGet(
"http://api.fitbit.com/oauth/request_token?oauth_consumer_key=7af733f021f649bcac32f6f7a4fe2e9a&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1358921319&oauth_nonce=456236281&oauth_callback=http://www.androidhub4you.com/&oauth_version=1.0&oauth_token=5cefb18d2a80073520211f03f8d75321&oauth_signature=QdVUzMvT6tveGyoPu%2BEevzvo07s%3D");
response = client.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
String webServiceInfo = "";
while ((webServiceInfo = rd.readLine()) != null) {
Log.e("****Step 1***", "Webservice: " + webServiceInfo);
authToken = webServiceInfo.substring(12, 44);
Log.e("Auth token:", "Webservice: " + authToken);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
和得到的authToken后,我打开一个网页,但我无力回 在我的应用程序了。
And after getting authToken I open a web page but I am unable to back on my application again.
private void openURL() {
webView.loadUrl("https://www.fitbit.com/oauth/authorize?oauth_token="
+ authToken + "&display=touch");
}
有人请帮助我的,如果有一个人有工作在非常紧迫 fitbit请帮助我。
some one please help me its very urgent if some one have work on fitbit please help me.
推荐答案
最后,我得到了我自己的问题的答案 -
Finally I got answer of my own question-
try {
HttpResponse response = null;
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 20000);
HttpConnectionParams.setSoTimeout(httpParameters, 20000);
HttpClient client = new DefaultHttpClient(httpParameters);
HttpGet request = new HttpGet(
"http://api.fitbit.com/oauth/request_token?oauth_consumer_key=7af733f021f649bcac32f6f7a4fe2e9a&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1358921319&oauth_nonce=456236281&oauth_callback=http://www.androidhub4you.com/&oauth_version=1.0&oauth_token=5cefb18d2a80073520211f03f8d75321&oauth_signature=QdVUzMvT6tveGyoPu%2BEevzvo07s%3D");
response = client.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
String webServiceInfo = "";
while ((webServiceInfo = rd.readLine()) != null) {
Log.e("****Step 1***", "Webservice: " + webServiceInfo);
authToken = webServiceInfo.substring(12, 44);
Log.e("Auth token:", "Webservice: " + authToken);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
在这之后 -
And after that-
String fitUrl = "https://www.fitbit.com/oauth/authorize?oauth_token="
+ authToken +"&display=touch";
webView.loadUrl(fitUrl);
Intent intent = new Intent(FitBitActivity.this, DashboardActivity.class);
pActivity.finishChildActivity(intent);
编辑: 你可以从这里下载的zip code -
you can download zip code from here-
的http://www.androidhub4you.com/2013/11/fitbit-integration-in-android-login.html
https://github.com/manishsri01/FitbitIntegration
这篇关于在Android的Fitbit账户整合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!