02-04-2016 05:55
02-04-2016 05:55
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..
02-04-2016 06:02 - edited 02-04-2016 06:04
02-04-2016 06:02 - edited 02-04-2016 06:04
Hi @Saket89
Moved this thread from the Android to the Web API section to increase the chance of getting a solution.
02-04-2016 06:07
02-04-2016 06:07
Thank you @SunsetRunner
02-04-2016 14:12
02-04-2016 14:12
@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?
02-04-2016 22:11
02-04-2016 22:11
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;
}
02-12-2016 00:47
02-12-2016 00:47
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