2013-10-18 41 views
1

我在运行时创建了一个线程。每个线程从肥皂中获取文件。我一次下载多个文件。但线程超过350 kb的文件不下载。如何解决这个问题呢?我是Android的初学者。线程文件在android下载?

+0

发布您的代码和logcat值! – r4jiv007

+0

请分享代码花花公子。 – 2013-10-18 11:40:32

+0

线程获取文件(21597):文件编号:39 \t文件类型:布局\t当前线程[Ljava.lang.StackTraceElement; @ 40cf1d68 线程获取文件(21597):文件ID:0 \t文件类型:媒体\t当前线程[ Ljava.lang.StackTraceElement; @ 417b03d8 –

回答

1
use **intent service** dear it will always running while your process is not completed 



public class MyIntentService extends IntentService { 







    public MyIntentService() { 
     super("com.example.androidintentservice.MyIntentService"); 
    } 

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

    } 

    @Override 
    protected void onHandleIntent(Intent intent) { 

     try { 
          DO YOUR TASK HERE 



      } 



     } catch (Exception e) { 
      e.printStackTrace(); 

     } 

     // return result 
     Intent intentResponse = new Intent(); 
     intentResponse.setAction(ACTION_MyIntentService); 
     intentResponse.addCategory(Intent.CATEGORY_DEFAULT); 
     intentResponse.putExtra(EXTRA_KEY_OUT, extraOut); 
     sendBroadcast(intentResponse); 
    } 



} 
+0

它解决了这个问题吗? @Bhanu Sharma –

+0

是的100%任何你想做的任务只是在这个意图服务中做的,它永远不会崩溃,直到你的工作没有完成 –

+0

我已经完全使用线程。可能吗。 –