AsyncTask类有时会崩溃

时间:2011-11-27 22:39:07

标签: android android-asynctask

这是我的AsyncTask类:

public class BackgroundAsyncTask extends
       AsyncTask<Void, Integer, Void> {
          private ProgressDialog dialog;
        int myProgress;

        @Override
        protected void onPostExecute(Void result) {
            // TODO Auto-generated method stub

             dialog.dismiss();


        }

        @Override
        protected void onPreExecute() {
            // TODO Auto-generated method stub
              dialog = ProgressDialog.show(nea.this, "", "Loading. Please wait...", true);
            myProgress = 0;
        }

        @Override
        protected Void doInBackground(Void... params) {
            // TODO Auto-generated method stub
            Intent newActivity1 = new Intent(nea.this, nea.class);     
         startActivity(newActivity1);
         finish();
            return null;
        }



    }
}

有什么问题吗?因为有时装载栏会冻结,然后洞穴应用程序也会冻结!!谢谢

@jan:

logcat的

DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0)
"main" prio=5 tid=1 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x400281b8 self=0xcec0
  | sysTid=12589 nice=0 sched=0/0 cgrp=default handle=-1345006496
  | schedstat=( 642386069 373380340 724 )
  at org.apache.harmony.luni.platform.OSNetworkSystem.read(Native Method)
  at dalvik.system.BlockGuard$WrappedNetworkSystem.read(BlockGuard.java:273)
  at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:458)
  at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:85)
  at java.io.BufferedInputStream.read(BufferedInputStream.java:319)
  at org.apache.harmony.luni.internal.net.www.protocol.http.ChunkedInputStream.read(ChunkedInputStream.java:50)
  at java.io.InputStream.read(InputStream.java:157)
  at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:516)
  at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:479)
  at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:318)
  at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:275)
  at android.util.Xml.parse(Xml.java:87)
  at kostas.menu.olympiakos.BaseFeedParser.parse(BaseFeedParser.java:92)
  at kostas.menu.olympiakos.nea.loadFeed(nea.java:77)
  at kostas.menu.olympiakos.nea.onCreate(nea.java:60)
  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:123)
  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)

"AsyncTask #1" prio=5 tid=8 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x405381b8 self=0x184400
  | sysTid=12636 nice=10 sched=0/0 cgrp=bg_non_interactive handle=1428144
  | schedstat=( 1854290 8663793 7 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x40538390> (a java.lang.VMThread)
  at java.lang.Thread.parkFor(Thread.java:1424)
  at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
  at sun.misc.Unsafe.park(Unsafe.java:337)
  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2016)
  at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:411)
  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1021)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
  at java.lang.Thread.run(Thread.java:1019)

"Binder Thread #2" prio=5 tid=7 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x40521a58 self=0x146340
  | sysTid=12595 nice=0 sched=0/0 cgrp=default handle=569336
  | schedstat=( 5603297 59082045 38 )
  at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #1" prio=5 tid=6 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x4051cf90 self=0x89ae0
  | sysTid=12594 nice=0 sched=0/0 cgrp=default handle=1010872
  | schedstat=( 6379499 47166754 35 )
  at dalvik.system.NativeStart.run(Native Method)

"Compiler" daemon prio=5 tid=5 VMWAIT
  | group="system" sCount=1 dsCount=0 obj=0x40518f10 self=0xf6660
  | sysTid=12593 nice=0 sched=0/0 cgrp=default handle=1002816
  | schedstat=( 116901382 108843724 347 )
  at dalvik.system.NativeStart.run(Native Method)

"Signal Catcher" daemon prio=5 tid=4 RUNNABLE
  | group="system" sCount=0 dsCount=0 obj=0x40518e50 self=0xf6448
  | sysTid=12592 nice=0 sched=0/0 cgrp=default handle=1007560
  | schedstat=( 1991126 320458 8 )
  at dalvik.system.NativeStart.run(Native Method)

"GC" daemon prio=5 tid=3 VMWAIT
  | group="system" sCount=1 dsCount=0 obj=0x40518da8 self=0xf6228
  | sysTid=12591 nice=0 sched=0/0 cgrp=default handle=479464
  | schedstat=( 61308130 27016339 27 )
  at dalvik.system.NativeStart.run(Native Method)

"HeapWorker" daemon prio=5 tid=2 VMWAIT
  | group="system" sCount=1 dsCount=0 obj=0x40518cf0 self=0xf6038
  | sysTid=12590 nice=0 sched=0/0 cgrp=default handle=1002936
  | schedstat=( 53410170 3467582 33 )
  at dalvik.system.NativeStart.run(Native Method)

0 个答案:

没有答案