You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for sharing, I'm using a moto (9) play, it seems to be working but I had to apply two minor changes:
.toDouble() was failing with an exception invalid input 0,00, perhaps the locale I guess, so I used a different approach to trim the distance to two decimals.
ACTIVITY_RECOGNITION is needed since api level 29
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c6af43e..dedc7a0 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,6 +3,7 @@
package="com.daniyalak.stepcounterkotlin_androidfitnessapp">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
+ <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
<application
android:allowBackup="true"
diff --git a/app/src/main/java/com/daniyalak/stepcounterkotlin_androidfitnessapp/helper/GeneralHelper.kt b/app/src/main/java/com/daniyalak/stepcounterkotlin_androidfitnessapp/helper/GeneralHelper.kt
index 25ed797..73aac13 100644
--- a/app/src/main/java/com/daniyalak/stepcounterkotlin_androidfitnessapp/helper/GeneralHelper.kt
+++ b/app/src/main/java/com/daniyalak/stepcounterkotlin_androidfitnessapp/helper/GeneralHelper.kt
@@ -59,7 +59,7 @@ class GeneralHelper {
fun getDistanceCovered(steps: Int): String? {
val feet = (steps * 2.5).toInt()
val distance = feet/3.281
- val finalDistance:Double = String.format("%.2f", distance).toDouble()
+ val finalDistance:Double = Math.round(distance * 100) / 100.0
return "$finalDistance meter"
}
}
The text was updated successfully, but these errors were encountered:
Thanks for sharing, I'm using a moto (9) play, it seems to be working but I had to apply two minor changes:
.toDouble() was failing with an exception invalid input 0,00, perhaps the locale I guess, so I used a different approach to trim the distance to two decimals.
ACTIVITY_RECOGNITION is needed since api level 29
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c6af43e..dedc7a0 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,6 +3,7 @@
package="com.daniyalak.stepcounterkotlin_androidfitnessapp">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
+ <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
<application
android:allowBackup="true"
diff --git a/app/src/main/java/com/daniyalak/stepcounterkotlin_androidfitnessapp/helper/GeneralHelper.kt b/app/src/main/java/com/daniyalak/stepcounterkotlin_androidfitnessapp/helper/GeneralHelper.kt
index 25ed797..73aac13 100644
--- a/app/src/main/java/com/daniyalak/stepcounterkotlin_androidfitnessapp/helper/GeneralHelper.kt
+++ b/app/src/main/java/com/daniyalak/stepcounterkotlin_androidfitnessapp/helper/GeneralHelper.kt
@@ -59,7 +59,7 @@ class GeneralHelper {
fun getDistanceCovered(steps: Int): String? {
val feet = (steps * 2.5).toInt()
val distance = feet/3.281
- val finalDistance:Double = String.format("%.2f", distance).toDouble()
+ val finalDistance:Double = Math.round(distance * 100) / 100.0
return "$finalDistance meter"
}
}
Thanks for sharing, I'm using a moto (9) play, it seems to be working but I had to apply two minor changes:
.toDouble()
was failing with an exceptioninvalid input 0,00
, perhaps the locale I guess, so I used a different approach to trim the distance to two decimals.The text was updated successfully, but these errors were encountered: