{"record":{"id":"85492d0779df92f9","repo":"microg/GmsCore","slug":"active-time-is-not-set","errorCode":null,"errorMessage":"Active time is not set","messagePattern":"Active time is not set","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"play-services-fitness/src/main/java/com/google/android/gms/fitness/data/Session.java","lineNumber":90,"sourceCode":"        this.startTimeMillis = startTimeMillis;\n        this.endTimeMillis = endTimeMillis;\n        this.name = name;\n        this.identifier = identifier;\n        this.description = description;\n        this.activityType = activityType;\n        this.application = application;\n        this.activeTimeMillis = activeTimeMillis;\n    }\n\n    /**\n     * Returns the active time period of the session.\n     * <p>\n     * Make sure to use {@link #hasActiveTime()} before using this method.\n     *\n     * @throws IllegalStateException {@link #hasActiveTime()} returns false.\n     */\n    public long getActiveTime(@NonNull TimeUnit timeUnit) {\n        if (activeTimeMillis == null) throw new IllegalStateException(\"Active time is not set\");\n        return timeUnit.convert(activeTimeMillis, TimeUnit.MILLISECONDS);\n    }\n\n    /**\n     * Returns the activity associated with this session, if set. Else returns {@link FitnessActivities#UNKNOWN}.\n     */\n    @NonNull\n    public String getActivity() {\n        return null; // TODO\n    }\n\n    /**\n     * Returns the package name for the application responsible for adding the session. or {@code null} if unset/unknown. The {@link PackageManager} can be\n     * used to query relevant data on the application, such as the name, icon, or logo.\n     */\n    @Nullable\n    public String getAppPackageName() {\n        if (application == null) return null;","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-fitness/src/main/java/com/google/android/gms/fitness/data/Session.java#L72-L108","documentation":"State access guard in Session.getActiveTime: the optional active-time field was not set when the Session was created, so there is no value to return. hasActiveTime() is the documented pre-check and returns false exactly when this throws.","triggerScenarios":"Thrown at play-services-fitness/src/main/java/com/google/android/gms/fitness/data/Session.java:90 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call hasActiveTime() before getActiveTime() and branch on the result","Fall back to endTime - startTime as an approximation when active time is unset"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}