2

私は、アプリケーションに FitBit デバイスを実装する必要がある医療科学に関連するアプリケーションに取り組んでいます。

FitBit 開発者ツールに従っていますが、統合できません。FitBit ライブラリを使用せずに手動で行っている場合、認証後にアプリケーションに戻ることができません。

私のコードは以下です-

    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 を取得した後、Web ページを開きましたが、アプリケーションに戻ることができません。

      private void openURL() {
                webView.loadUrl("https://www.fitbit.com/oauth/authorize?oauth_token="
                        + authToken + "&display=touch");
            }
4

2 に答える 2

5

最後に、私は自分の質問の答えを得ました-

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();
        }

それとその後-

    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);

編集: ここから郵便番号をダウンロードできます-

http://www.androidhub4you.com/2013/11/fitbit-integration-in-android-login.html

https://github.com/manishsri01/FitbitIntegration

于 2013-02-13T06:26:17.797 に答える