Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Android Fitbit third party app integration

After calling the fitbit authorize api and after the user allows the permission the application closes and again I have to start the application to open the activity which i have provided as the redirect_uri, so is there any workaround that it directly goes into the activity without the application getting closed..

Best Answer
0 Votes
5 REPLIES 5

Hi @Saket89

 

Moved this thread from the Android to the Web API section to increase the chance of getting a solution.

Best Answer
0 Votes

Thank you @SunsetRunner

Best Answer

@Saket89 wrote:

After calling the fitbit authorize api and after the user allows the permission the application closes and again I have to start the application to open the activity which i have provided as the redirect_uri, so is there any workaround that it directly goes into the activity without the application getting closed..


Which application—yours?

Best Answer

Its an health application called alivemeter in which I need to integrate fitbit but after granting the permission from the user the application closes.. 

 

below is the code that I have written to get the access token

 

  private static class NavigationCallback extends CustomTabsCallback {
@Override
public void onNavigationEvent(int navigationEvent, Bundle extras) {
// extras.getString("access")
Log.w("FITBIT", "onNavigationEvent: Code = " + navigationEvent);
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(getSession());
customTabsIntent = builder.build();



String url = "https://www.fitbit.com/oauth2/authorize?" +
"response_type=token" +
"&client_id=******" +
"&scope=activity"+
"&redirect_uri=fitbitdemo://alivemeter";
customTabsIntent.launchUrl(MainActivity.this, Uri.parse(url));
}

private CustomTabsSession getSession() {
if (mClient == null) {
mCustomTabsSession = null;
} else if (mCustomTabsSession == null) {
mCustomTabsSession = mClient.newSession(new NavigationCallback());
}
return mCustomTabsSession;
}

 

Best Answer

I have the same problem in a real device.
When I use the emulator (Android Studio with Genymotion without Chrome) it works.
But, when I use a real device with Chrome and Custom Tabs it doesn't work. When the app is installed for first, it works and I save the (client) token in my sharedpreferences. But if I delete the sharedpreferences and I try to reconnect to Fitbit, the Chrome Custom Tab is opened and closed and I have to open manually again my app

Best Answer
0 Votes