第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

length = is.read(buffer) length =1 這個(gè)是什么原因啊

public void run() {

// 數(shù)據(jù)庫(kù)插入線程信息

// 線程 下載位置 寫(xiě)入位置

// 開(kāi)始下載了

HttpURLConnection conn = null;

if (!mDao.isExists(threadInfo.getUrl(), threadInfo.getId())) {

mDao.insertThread(threadInfo);

}

try {

URL url = new URL(threadInfo.getUrl());

conn = (HttpURLConnection) url.openConnection();

conn.setConnectTimeout(3000);

conn.setRequestMethod("GET");

int start = threadInfo.getStart() + threadInfo.getFinised();

conn.setRequestProperty("Range", "bytes=" + start + "-"

+ threadInfo.getEnd());

File file = new File(DownloadService.DOWNLOAD_PATH,

fileInfo.getName());

raf = new RandomAccessFile(file, "rwd");

raf.seek(start);// 設(shè)置文件的寫(xiě)入位置

// 開(kāi)始下載

Intent intent = new Intent(DownloadService.ACTION_UPDATE);

mFinished += threadInfo.getFinised();

// 部分下載 206

if (conn.getResponseCode() == HttpStatus.SC_PARTIAL_CONTENT) {// 讀取數(shù)據(jù)

is = conn.getInputStream();

byte[] buffer = new byte[1024 * 4];

int length = -1;

long time = System.currentTimeMillis();

while ((length = is.read(buffer)) != -1) {

raf.write(buffer, 0, length);

Log.e("length",length+"");

// 發(fā)送進(jìn)度

mFinished += length;

Log.e("mFinished",mFinished+"");

if (System.currentTimeMillis() - time > 500) {

time = System.currentTimeMillis();

intent.putExtra("finished", mFinished * 100

/fileInfo.getLength());

Log.e("==1",intent.toString());?

context.sendBroadcast(intent);

}

Log.e("isPause",isPause+"");

if (isPause) {

mDao.updateThread(threadInfo.getUrl(),

threadInfo.getId(), mFinished);

return;

}

}

}

// 寫(xiě)入到文件

// 下載暫停 保存進(jìn)度

// 下載進(jìn)度發(fā)送廣播

mDao.deleteThread(threadInfo.getUrl(), threadInfo.getId());

} catch (Exception e) {

e.printStackTrace();

} finally {

try {

is.close();

raf.close();

} catch (IOException e) {

e.printStackTrace();

}

conn.disconnect();

}

}


正在回答

1 回答

我也是碰到這個(gè)問(wèn)題了的,下面是我的解決辦法,

shexyptebhbvusougjmcrxjumkbffqdlsdgftdcylfiouqxzdmabzvercuxxzvovtmmvwohoxqmgtxnafykkwdpovonztolxvmgrfrqsbdzjtvqvlfic

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
Android-Service系列之?dāng)帱c(diǎn)續(xù)傳下載
  • 參與學(xué)習(xí)       20431    人
  • 解答問(wèn)題       103    個(gè)

想升職加薪么?本章課程你值得擁有,滿滿的干貨,學(xué)起來(lái)吧

進(jìn)入課程

length = is.read(buffer) length =1 這個(gè)是什么原因啊

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)