我正在使用一项服务从网络上下载大量文件。但是在下载文件时,我无法与该应用程序进行交互。什么是最好的方法。 我正在下载大约 10 MB 的文件,我希望用户在下载文件时与应用程序交互 请找到我的服务代码。
public static class MyService extends Service {
@Override
public IBinder onBind(Intent arg0) {
return null;
}
public MyService(){
super();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// Let it continue running until it is stopped.
System.out.println("service started");
Toast.makeText(this, "Service Started", Toast.LENGTH_LONG).show();
//Toast.makeText(Description.this, "Downloading content...", Toast.LENGTH_LONG);
GetShowsInfo(downloadEpisodeMedia(episode_id));
RequestDownloads();
File cacheDir=new File(android.os.Environment.getExternalStorageDirectory(),"Folder Name");
listf(cacheDir,files);
mediaPlayerflag=true;
//progressBarLayout.setVisibility(LinearLayout.VISIBLE);
nowPlayingEpisode=categoryName;
//NowPlayingEpisode.setText("Now Playing "+episodeArrayList.get(position).getName());
textView_MediaPlayer.setText(nowPlayingEpisode);
//textView_EpisodeCount.setText(episodeCount);
playOnebyOneMedia();
// StoreInfo(GetCategories());
//StoreDescription(GetDescription());
return START_STICKY;
}
@Override
public void onDestroy() {
System.out.println("service stopped");
super.onDestroy();
Toast.makeText(this, "Service Destroyed", Toast.LENGTH_LONG).show();
}
}