I need a duration of the route. It would be great if we can get duration with include traffic and exclude traffic both.
We can get distance of a route, but I need duration of that route.
I assume you talk about the Premium HERE Mobile SDK ?
In a short:
1) Route calculation needs to happen with traffic request:
DynamicPenalty dp = new DynamicPenalty();
dp.setTrafficPenaltyMode(Route.TrafficPenaltyMode.OPTIMAL);
CoreRouter cr = new CoreRouter();
cr.setDynamicPenalty(dp);
See https://developer.here.com/documentation/android-premium/api_reference_java/com/here/android/mpa/routing/Route.TrafficPenaltyMode.html as reference.
2) When you get back a route object, it contains all information you want. You can query the data via getTtaIncludingTraffic or getTtaExcludingTraffic methods, see: https://developer.here.com/documentation/android-premium/api_reference_java/com/here/android/mpa/routing/Route.html#getTta-com.here.android.mpa.routing.Route.TrafficPenaltyMode-int-
Additionally if you want to see more code, you can check out the HERE UI Components for the SDK here https://github.com/heremaps/msdkui-android where your usecase is also implemented (since it's open source you can have a look in the code how it's done there).