Android - AsynchTask调用的异常

时间:2012-04-06 18:48:14

标签: android

我有一个Activity,它进行远程服务器调用并尝试填充列表。对服务器的调用工作正常,调用返回一些好的JSON。

但是系统抛出了这个异常:

04-06 18:43:19.626: D/AndroidRuntime(2564): Shutting down VM
04-06 18:43:19.626: W/dalvikvm(2564): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
04-06 18:43:19.686: E/AndroidRuntime(2564): FATAL EXCEPTION: main
04-06 18:43:19.686: E/AndroidRuntime(2564): java.lang.NullPointerException
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.widget.AbsListView.obtainView(AbsListView.java:2033)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1244)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.widget.ListView.onMeasure(ListView.java:1155)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.view.View.measure(View.java:12723)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1369)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:660)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.view.View.measure(View.java:12723)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.view.View.measure(View.java:12723)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:812)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.view.View.measure(View.java:12723)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2092)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.view.View.measure(View.java:12723)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1064)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.os.Looper.loop(Looper.java:137)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at android.app.ActivityThread.main(ActivityThread.java:4424)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at java.lang.reflect.Method.invokeNative(Native Method)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at java.lang.reflect.Method.invoke(Method.java:511)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-06 18:43:19.686: E/AndroidRuntime(2564):     at dalvik.system.NativeStart.main(Native Method)

为什么会这样?它没有指向我的任何代码所以它有点奇怪。

protected void onPostExecute(String result)永远不会在回调中被调用。

谢谢!

1 个答案:

答案 0 :(得分:2)

你应该为我们发布你的AsyncTask以获得完整的图片,但是从日志我会告诉你,你正试图在doInBackground()中夸大一些视图。只允许用户界面互动onPostExecute()。如果不是这样,请发布您的代码。