gpt4 book ai didi

java - publishProgress()导致崩溃

转载 作者:行者123 更新时间:2023-12-02 11:05:22 25 4
gpt4 key购买 nike

当我尝试下载文件时,应用程序崩溃。
问题是当我刷新进度条时。我使用asynctask.The错误是这样的:

while ((read = is.read(buffer, 0, 1024)) > 0) {

totalRead += read;
//System.out.println(totalRead);
String progress = ("" + ((int) (totalRead * 100)) / lenghtOfFile);
System.out.println(progress);
/Here/ publishProgress(progress);

cos.write(buffer, 0, read);
}

LogCat:
W/Bundle: Attempt to cast generated internal exception:
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at android.os.Bundle.getInt(Bundle.java:940)
at com.android.server.am.MultiWindowManagerService.getDefaultWindowInfoLocked(MultiWindowManagerService.java:479)
at com.android.server.am.MultiWindowManagerService.addWindowInfo(MultiWindowManagerService.java:317)
at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:2394)
at com.android.server.am.ActivityStack.startActivityUncheckedLocked(ActivityStack.java:3782)
at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:3377)
at com.android.server.am.ActivityStack.startActivityMayWait(ActivityStack.java:3946)
at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:2651)
at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:148)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1734)
at android.os.Binder.execTransact(Binder.java:367)
at dalvik.system.NativeStart.run(Native Method)
06-24 22:13:21.541 2271-2807/? W/Bundle: Key com.sec.android.multiwindow.DEFAULT_SIZE_H expected Integer but value was a java.lang.String. The default value 0 was returned.
06-24 22:13:21.546 2654-2654/? W/ResourceType: Attempt to retrieve bag 0x01030068 which is invalid or in a cycle.
06-24 22:13:21.546 2271-2807/? W/Bundle: Attempt to cast generated internal exception:
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at android.os.Bundle.getInt(Bundle.java:940)
at com.android.server.am.MultiWindowManagerService.getDefaultWindowInfoLocked(MultiWindowManagerService.java:483)
at com.android.server.am.MultiWindowManagerService.addWindowInfo(MultiWindowManagerService.java:317)
at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:2394)
at com.android.server.am.ActivityStack.startActivityUncheckedLocked(ActivityStack.java:3782)
at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:3377)
at com.android.server.am.ActivityStack.startActivityMayWait(ActivityStack.java:3946)
at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:2651)
at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:148)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1734)
at android.os.Binder.execTransact(Binder.java:367)
at dalvik.system.NativeStart.run(Native Method)
06-24 22:13:21.546 2271-2807/? W/Bundle: Key com.sec.android.multiwindow.MINIMUM_SIZE_W expected Integer but value was a java.lang.String. The default value 0 was returned.
06-24 22:13:21.551 2271-2807/? W/Bundle: Attempt to cast generated internal exception:
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at android.os.Bundle.getInt(Bundle.java:940)
at com.android.server.am.MultiWindowManagerService.getDefaultWindowInfoLocked(MultiWindowManagerService.java:488)
at com.android.server.am.MultiWindowManagerService.addWindowInfo(MultiWindowManagerService.java:317)
at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:2394)
at com.android.server.am.ActivityStack.startActivityUncheckedLocked(ActivityStack.java:3782)
at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:3377)
at com.android.server.am.ActivityStack.startActivityMayWait(ActivityStack.java:3946)
at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:2651)
at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:148)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1734)
at android.os.Binder.execTransact(Binder.java:367)
at dalvik.system.NativeStart.run(Native Method)
06-24 22:13:21.551 2271-2807/? W/Bundle: Key com.sec.android.multiwindow.MINIMUM_SIZE_H expected Integer but value was a java.lang.String. The default value 0 was returned.
06-24 22:13:21.551 2271-2807/? W/Bundle: Attempt to cast generated internal exception:
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at android.os.Bundle.getInt(Bundle.java:940)
at com.android.server.am.MultiWindowManagerService.getDefaultWindowInfoLocked(MultiWindowManagerService.java:492)
at com.android.server.am.MultiWindowManagerService.addWindowInfo(MultiWindowManagerService.java:317)
at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:2394)
at com.android.server.am.ActivityStack.startActivityUncheckedLocked(ActivityStack.java:3782)
at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:3377)
at com.android.server.am.ActivityStack.startActivityMayWait(ActivityStack.java:3946)
at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:2651)
at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:148)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1734)
at android.os.Binder.execTransact(Binder.java:367)
at dalvik.system.NativeStart.run(Native Method)

最佳答案

我想你试图更改doInBackground内的UI(查看元素),必须在onPostExecute中进行更改

但只有当您显示publishProgress的代码时,我们才能确定找到它。

关于java - publishProgress()导致崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17284393/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com