gpt4 book ai didi

android - ActivityManager 中的 ANR keyDispatchingTimedOut

转载 作者:行者123 更新时间:2023-11-30 04:19:37 24 4
gpt4 key购买 nike

我的应用程序“ActivityManager 中的 ANR keyDispatchingTimedOut”收到以下崩溃报告。生成的 logCat 如下所示。谁能告诉我错误到底发生在哪里?我尝试了很多,但我无法再次重现错误。它出现一次,之后就不再显示了,尽管我没有采取任何措施来修复错误。

**Log Cat Report**

DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0)
"main" prio=5 tid=1 SUSPENDED
| group="main" sCount=1 dsCount=0 obj=0x400281c0 self=0xce38
| sysTid=7464 nice=0 sched=0/0 cgrp=default handle=-1345006496
| schedstat=( 58625349214 2714690161 19132 )
at java.lang.String._getChars(String.java:~1041)
at java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:89)
at java.lang.StringBuilder.<init>(StringBuilder.java:96)
at in.plackal.lovecyclesfree.CycleManager.readNotesFromFile(CycleManager.java:1995)
at in.plackal.lovecyclesfree.CycleManager.readFromRegister(CycleManager.java:1717)
at in.plackal.lovecyclesfree.ActivityManager.onStart(ActivityManager.java:53)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
at android.app.Activity.performStart(Activity.java:3791)
at android.app.Activity.performRestart(Activity.java:3821)
at android.app.Activity.performResume(Activity.java:3826)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2114)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:961)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
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:847)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
at dalvik.system.NativeStart.main(Native Method)

"DispatcherThread" prio=5 tid=8 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x406606e8 self=0x16a280
| sysTid=7744 nice=0 sched=0/0 cgrp=default handle=1378768
| schedstat=( 7404750 4921250 23 )
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:119)
at android.os.Looper.loop(Looper.java:117)
at android.os.HandlerThread.run(HandlerThread.java:60)

"Binder Thread #3" prio=5 tid=33 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x405cfb58 self=0x3e1f20
| sysTid=7610 nice=0 sched=0/0 cgrp=default handle=3996712
| schedstat=( 6275204 26755586 40 )
at dalvik.system.NativeStart.run(Native Method)

"WebViewWorkerThread" prio=5 tid=32 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x405b6b48 self=0x37ed10
| sysTid=7608 nice=1 sched=0/0 cgrp=default handle=3665480
| schedstat=( 95768014 64209212 111 )
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:119)
at android.os.Looper.loop(Looper.java:117)
at android.os.HandlerThread.run(HandlerThread.java:60)

"http19" prio=5 tid=31 WAIT
| group="main" sCount=1 dsCount=0 obj=0x405c4a30 self=0x37dac8
| sysTid=7607 nice=1 sched=0/0 cgrp=default handle=3660800
| schedstat=( 92166 313457 4 )
at java.lang.Object.wait(Native Method)
- waiting on <0x405f0640> (a android.net.http.RequestQueue)
at java.lang.Object.wait(Object.java:358)
at android.net.http.ConnectionThread.run(ConnectionThread.java:98)

"http18" prio=5 tid=30 WAIT
| group="main" sCount=1 dsCount=0 obj=0x405c4798 self=0x37c898
| sysTid=7606 nice=1 sched=0/0 cgrp=default handle=3656144
| schedstat=( 59249 73000 3 )
at java.lang.Object.wait(Native Method)
- waiting on <0x405f0640> (a android.net.http.RequestQueue)
at java.lang.Object.wait(Object.java:358)
at android.net.http.ConnectionThread.run(ConnectionThread.java:98)

"http17" prio=5 tid=29 WAIT
| group="main" sCount=1 dsCount=0 obj=0x405c45c0 self=0x37b650
| sysTid=7605 nice=1 sched=0/0 cgrp=default handle=3651464
| schedstat=( 63708 79043 4 )
at java.lang.Object.wait(Native Method)
- waiting on <0x405f0640> (a android.net.http.RequestQueue)
at java.lang.Object.wait(Object.java:358)
at android.net.http.ConnectionThread.run(ConnectionThread.java:98)

"http16" prio=5 tid=28 WAIT
| group="main" sCount=1 dsCount=0 obj=0x405c43e8 self=0x37a408
| sysTid=7604 nice=1 sched=0/0 cgrp=default handle=3646784
| schedstat=( 58542 109166 3 )
at java.lang.Object.wait(Native Method)
- waiting on <0x405f0640> (a android.net.http.RequestQueue)
at java.lang.Object.wait(Object.java:358)
at android.net.http.ConnectionThread.run(ConnectionThread.java:98)

"http15" prio=5 tid=27 WAIT
| group="main" sCount=1 dsCount=0 obj=0x405c4210 self=0x3791d8
| sysTid=7603 nice=1 sched=0/0 cgrp=default handle=3642128
| schedstat=( 64167 104083 3 )
at java.lang.Object.wait(Native Method)
- waiting on <0x405f0640> (a android.net.http.RequestQueue)
at java.lang.Object.wait(Object.java:358)
at android.net.http.ConnectionThread.run(ConnectionThread.java:98)

最佳答案

您可以将您的方法实现为

onStart 方法

@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();

doLongerTask();
}

处理时间较长的方法

private void doLongerTask() {
final ProgressDialog dialog = ProgressDialog.show(Client.this, "Please wait", "Doing long task...", true);
dialog.setCancelable(true);
//dialog = CustomProgressDialog.show(this, "", "");
new Thread() {
@Override
public void run() {
try{
//TODO Write here your method logic
sleep(5000);
} catch (Exception e) {
Log.i("your_app_tag", e.toString());
dialog.dismiss();
}
//Dismiss dialog, and notify handler to done this task
dialog.dismiss();
longTaskHandler.sendEmptyMessage(0);
}
}.start();
}

处理程序将在完成长时间处理后处理 UI 更改。

private Handler longTaskHandler = new Handler() {
@Override
public void handleMessage(Message msg) {

switch(msg.what) {
case 0:
//Here you can implement UI code. like if you are using listview
//then you can refresh listview.
break;
}
}
};

这不仅仅是一种方式。阅读here了解所有可能的方法。

快乐编码:)

关于android - ActivityManager 中的 ANR keyDispatchingTimedOut,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9460525/

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