My application works great while using the emulator, but it crashes while working on real device. I code it for Android 2.2. Real device is 2.3.6.
Problem is here:
When I use something like that:
tvPlayerOneScores.setText("-" + numberFormat.format(level));
it works great both on emulator and real device.
But when I try this:
tvPlayerOneScores.setText("-" + numberFormat.format(level * 0.5f));
it works on emulator, but crashes on real device.
Stack Trace:
java.lang.NumberFormatException
at org.apache.harmony.luni.util.FloatingPointParser.parseFltImpl(Native Method)
at org.apache.harmony.luni.util.FloatingPointParser.parseFloat(FloatingPointParser.java:321)
at java.lang.Float.parseFloat(Float.java:323)
at java.lang.Float.valueOf(Float.java:362)
at com.amrotek.truthordare.GameActivity$4.onClick(GameActivity.java:287)
at android.view.View.performClick(View.java:2552)
at android.view.View$PerformClick.run(View.java:9229)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3701)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
at dalvik.system.NativeStart.main(Native Method)
EDIT: I multiplied all values by 10, so I only work with integer numbers when I do arithmetic operations. At the end I just divide end value by 10. It works :)