Android fitbit 集成

Android fitbit integration

您好,我按照 fitbit 文档将 fitbit 集成到我的应用程序中。我的问题是一旦我对应用程序进行身份验证意味着它不会将我重定向到我的 andropid activity。我显示我的代码

button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = "https://www.fitbit.com/oauth2/authorize?response_type=code&client_id="
                        + cliend id + "&redirect_uri=" + redirect_uri + "&scope=" + "activity";
                Intent oauthIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                startActivity(oauthIntent);
            }
        });

在我的清单中

<intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="MyExample4" />
            </intent-filter>

它将我带到我的重定向page.Can任何遇到这个问题的人都请帮助我。

我不熟悉 fitbit,但根据我在您的代码中看到的内容,我可以说您的 intent 过滤器不完整。您可能应该使意图过滤器与您在身份验证 URL.

中嵌入的 redirect_uri 相匹配

一旦你实现了它并且用户正确验证了浏览器将导航到 redirect_uri 并且使用正确的 intent-filter 你将能够在你的应用程序中打开它。

代码可以如下:

将您的 redirect_uri 设置为 my-fitbit-app://my.fitbit.app/handle_auth

在你的intent-filter

<intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="my-fitbit-app" />
                <data android:host="my.fitbit.app" />
                <data android:path="/handle_auth" />
            </intent-filter>