Jan*_*iya -7 java android integer android-6.0-marshmallow
我非常清楚我在这里解析为Integer的值是Long值.
问题是:为什么它在Pre-Marshmallow工作?
这是我的代码:
public void print(long mili) {
Long serverUptimeSeconds =
(mili - System.currentTimeMillis()) / 1000;
String serverUptimeText =
String.format("%02d%02d%02d%02d",
Math.abs(serverUptimeSeconds) / 86400,
(Math.abs(serverUptimeSeconds) % 86400) / 3600,
((Math.abs(serverUptimeSeconds) % 86400) % 3600) / 60,
((Math.abs(serverUptimeSeconds) % 86400) % 3600) % 60
);
// compiler is giving error at this line in Marshmallow 6.0.1 only
tv.setValue(Integer.parseInt(serverUptimeText), false);
}
Run Code Online (Sandbox Code Playgroud)
我的职责:
public void setValue(int value, boolean withAnimation) {
mCurrentValue = value;
int tempValue = value;
for (int i = 7; i > 0; --i)
{
int factor = (int) Math.pow(10, i);
int digitVal = (int) Math.floor(tempValue / factor);
tempValue -= (digitVal * factor);
mDigitSpinners[i].setDigit(digitVal, withAnimation);
changeAnimationCompleteCounter(withAnimation);
}
mDigitSpinners[0].setDigit(tempValue, withAnimation);
changeAnimationCompleteCounter(withAnimation);
}
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪 :
java.lang.RuntimeException:无法启动活动ComponentInfo {com.srk/com.srk.DayPSearchActivity}:java.lang.NumberFormatException:无效的int:"16905104155"在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)的android.app.ActivityThread.-wrap11(ActivityThread.java)android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1354)在android.os .Handler.dispatchMessage(Handler.java:102)位于android.app.Looper.loop(Looper.java:148)的android.app.ActivityThread.main(ActivityThread.java:5443),位于java.lang.reflect.Method. com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:728)在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)中调用(Native Method)引起:java. lang.NumberFormatException:java.lang.Integer.parseI中java.lang.Integer.parse(Integer.java:413)的java.lang.Integer.invalidInt(Integer.java:138)中的int:"16905104155"无效 NT(Integer.java:367)
你试图解析一个int 16905104155,但它很长.
尝试将其解析为long, Long.parseLong(serverUptimeText)
| 归档时间: |
|
| 查看次数: |
1875 次 |
| 最近记录: |