配置AppWidget时广播超时

时间:2010-06-22 21:21:40

标签: android widget

在我的应用程序中,我已经重新添加了一个主屏幕小部件。除了第一次尝试添加小部件时,一切正常。而不是打开配置活动,ANR出现。

我猜测,因为它在第一次崩溃后工作正常,崩溃可能是由一些未定义的值引起的。或许我还没有理解有关appWidget的事情。

我的Receiver在清单中声明了元数据,该元数据指向用于首选项的活动。此活动由微调器和按钮组成。按下按钮时,“空”RemoteView将传递给主机,广播将发送到我的服务,该服务将尝试从服务器加载数据。我是否需要在用户交互之前将RemoteView传递给主机?

日志条目对我没有意义。我希望有人比我更了解日志输出:

I/ActivityManager(   51): Displayed activity com.android.settings/.AppWidgetPickActivity: 1086 ms (total 21908 ms)
E/my-appWidgetProvider(  228): BroadcastReciever enabled
D/AndroidRuntime(  228): Shutting down VM
W/dalvikvm(  228): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
I/ActivityManager(   51): Starting activity: Intent { act=android.appwidget.action.APPWIDGET_CONFIGURE cmp=se.oskarnordgren.debaser/.widget.WidgetPrefs (has extras) }
W/InputManagerService(   51): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@43922578
W/WindowManager(   51): Attempted to add window with non-application token WindowToken{43890b08 token=null}.  Aborting.
D/dalvikvm(  228): DestroyJavaVM waiting for non-daemon threads to exit
W/ActivityManager(   51): Timeout of broadcast BroadcastRecord{438c3308 android.appwidget.action.APPWIDGET_UPDATE} - receiver=android.os.BinderProxy@4393cfe8
W/ActivityManager(   51): Receiver during timeout: ResolveInfo{438c3288 se.oskarnordgren.debaser.widget.DebaserWidget p=0 o=0 m=0x0}
I/ActivityManager(   51): ANR in process: se.oskarnordgren.debaser
I/ActivityManager(   51): Annotation: Broadcast of Intent { act=android.appwidget.action.APPWIDGET_UPDATE cmp=se.oskarnordgren.debaser/.widget.DebaserWidget (has extras) }
I/ActivityManager(   51): CPU usage:
I/ActivityManager(   51): Load: 0.87 / 0.36 / 0.13
I/ActivityManager(   51): CPU usage from 10094ms to 20ms ago:
I/ActivityManager(   51):   com.android.settings: 6% = 3% user + 2% kernel / faults: 4014 minor 5 major
I/ActivityManager(   51):   system_server: 3% = 2% user + 1% kernel / faults: 12 minor
I/ActivityManager(   51):   logcat: 2% = 0% user + 1% kernel / faults: 108 minor
I/ActivityManager(   51):   android.process.acore: 0% = 0% user + 0% kernel / faults: 2 minor
I/ActivityManager(   51):   se.oskarnordgren.debaser: 0% = 0% user + 0% kernel / faults: 11 minor
I/ActivityManager(   51):   com.android.phone: 0% = 0% user + 0% kernel / faults: 2 minor
I/ActivityManager(   51):   adbd: 0% = 0% user + 0% kernel
I/ActivityManager(   51):   sh: 0% = 0% user + 0% kernel / faults: 98 minor
I/ActivityManager(   51): TOTAL: 5% = 3% user + 1% kernel
I/ActivityManager(   51): Removing old ANR trace file from /data/anr/traces.txt
I/Process (   51): Sending signal. PID: 228 SIG: 3
I/dalvikvm(  228): threadid=7: reacting to signal 3
I/dalvikvm(  228): Wrote stack trace to '/data/anr/traces.txt'

为什么我会收到ANR而不是android:configure中引用的活动?

如果我知道哪些部分在这里很重要,我可以粘贴更多代码。

1 个答案:

答案 0 :(得分:0)

这是一个老问题,仍然希望这个答案可以帮助其他人面对这个问题。

我们无法在广播接收器中调用getApplicationContext。如果你这样做可能会导致ANR。