當前位置:首頁 » 安卓系統 » androidhttp下載

androidhttp下載

發布時間: 2023-05-19 14:55:57

❶ android開發 關於http下載。

一是編碼問題?
二是位元組序問題轎盯?
-----------------------------------------------------------------------------------------------------
安卓精英團為你解答
安慧帆飢卓精英團歡迎各位精英前返加入

❷ android編程問題:通過HttpURLConnection下載文本。

sdk14版本及以上不能在UI主線程中請求網路,需要建立新線程,而14一下版本就沒有問題。創建新線程的方法在我一篇筆記中寫過,http://blog.csdn.net/chiyiw/article/details/38309085 ,之後我也寫了個查電話號碼歸屬地的Demo。要可以發給你。筆記里的代碼(這是線程間的通信,通信部分的代碼可以不要):

java">packageorg.wp.webservice02;

importandroid.app.Activity;
importandroid.os.Bundle;
importandroid.os.Handler;
importandroid.os.Message;
importandroid.widget.TextView;

{

privateTextViewinfo=null;

@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

info=(TextView)super.findViewById(R.id.info);

//創建一個新線則談程,用外部處理程序初始化,便於將線程的數據送回
MyThreadthread=newMyThread(handler);
//開始新線程
thread.start();
}

//handler:處理程序
Handlerhandler=newHandler(){

@Override
publicvoidhandleMessage(Messagemsg){
super.handleMessage(msg);

//接收消息裡面的包中的String數據
Stringstring=msg.getData().getString("key");
//將線程中的得到的數據顯示
info.setText(string);
}

};

{
privateHandler孫茄碰handler=null;

//初始化線程
protectedMyThread(Handlerhandler){
this.handler=handler;
}

@Override
//線程的start()執行時自動調用此函數
publicvoidrun(){
super.run();

//…………
//執行子線程里實現的功能
//…………

//線程中產生的數據,可以是任何類型的值,此納衫處用String類型作為例子
Stringstring="Hello,newThread!";
//定義消息,之後發送出去
Messagemsg=handler.obtainMessage();
//定義數據包,數據包里可以put不同類型的數據
Bundlebundle=newBundle();
//將String數據放入包中
bundle.putString("key",string);
//將包放入消息中
msg.setData(bundle);
//將消息發送出去
handler.sendMessage(msg);
}
}
}

❸ 安卓http下載導致socket斷網

安卓HTTP下載導致Socket斷網的可能原因有以下幾種:
1. 網路連接不穩定:如果網路連豎咐敗接不穩定,可能會導致Socket斷開連接。嘗試使用其他網路連接或在網路連接穩定的情況下進行下載。
2. 下載過程中出現錯誤:如果下載過程中出現錯誤,可能會導致Socket斷開連接。嘗試重新下載文件或使用其他下載工具進行下載。
3. 網路防火牆或代理設置問題:如果網路中存在防火牆或代理,可能會阻止Socket連接。檢查網路防火牆或代理設置,確保允許Socket連接。
4. 系統設置問題:如果系統設置不正確,可能會導致Socket斷開連接。嘗試重置網路設置或恢復出廠設置來解決問題。
5. 應用程序問題:如果應用程序余顫存在問題,可能會導致Socket斷開連接。簡咐嘗試更新應用程序或使用其他應用程序進行下載。
如果以上方法都無法解決問題,建議聯系網路管理員或技術支持人員尋求幫助。

❹ android 如何實現一次http請求下載過個文件如:請求http://192.168.1.2:8088/a.jsp,獲得a.jpg,b.jpg

如果在伺服器端向response裡面寫入多個文件的數據當然可以下載,只不過需要伺服器端和手機端的程序制定一個協議,比如手機端得到數據之後根據什麼規則切分成多個文件。

❺ android原生開發,從http下載圖片,下載失敗或成功提示,並放圖片顯示出來。

下載類
public class DownFile
{
public InputStream getInput(String path)
{
InputStream in = null;
try {
URL url = new URL(path);
HttpURLConnection hcon = (HttpURLConnection) url.openConnection();
in = hcon.getInputStream();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return in;
}
public int downIamge(String path,String name)
{
InputStream in = getInput(path);
int type = 0;
File ex = Environment.getExternalStorageDirectory();
try {
FileOutputStream out = new FileOutputStream(new File(ex.getAbsoluteFile()+File.separator+name));
int len = 0;
byte[] bb = new byte[1024];
while((len = in.read(bb))!=-1)
{
out.write(bb,0,len);
}
out.close();
type = 1;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
type = 2;
}
return type;
}
}
2在另外一個activity裡面調用這個方法DownFile().downIamge(path,name); 返回1就是下載成功 ,2 就顯示下載失敗
自己手寫的 望採納 不懂 可繼續追問

❻ android通過http post實現文件下載

可參照我的如下代碼

java.io.OutputStreamos=null;
java.io.InputStreamis=null;
try{
java.io.Filefile=newjava.io.File(str_local_file_path);
if(file.exists()&&file.length()>0){
}else{
file.createNewFile();

java.net.URLurl=newjava.net.URL(str_url);
java.net.HttpURLConnectionconn=(java.net.HttpURLConnection)url.openConnection();
os=newjava.io.FileOutputStream(file);
is=conn.getInputStream();
byte[]buffer=newbyte[1024*4];
intn_rx=0;
while((n_rx=is.read(buffer))>0){
os.write(buffer,0,n_rx);
}
}
returntrue;
}catch(MalformedURLExceptione){
}catch(IOExceptione){
}finally{
os.flush();
os.close();
is.close();
}
returnfalse;

❼ android手機下載連接http://fir.im/qjv4,APP去哪裡下載,

打開連接點擊下載即可

❽ Android開發 何如通過HTTP下載XML到手機(注:不是SD卡)

用httpurlconnection

❾ android http下載找不到文件

是版本過低,是你可以去 Android官網去下載

❿ android通過okhttp經常下載不完整

系統bug。android通過okhttp經常下載不完整是因為okhttp軟體系統出現了bug導致下載不完整,等待官方修復即可。系統一詞來源舉派則於正棚英文system的音羨春譯,即若幹部分相互聯系、相互作用,形成的具有某些功能的整體。

熱點內容
安卓手機已經鎖起來了怎麼刷機 發布:2025-02-13 06:35:01 瀏覽:882
安卓怎麼快速多選手機桌面圖標 發布:2025-02-13 06:21:51 瀏覽:298
androidia安裝 發布:2025-02-13 06:12:14 瀏覽:12
jsmcc文件夾 發布:2025-02-13 06:11:26 瀏覽:170
演算法與程序設計教案 發布:2025-02-13 06:10:51 瀏覽:55
ftp登錄需要輸入用戶名和密碼 發布:2025-02-13 06:03:33 瀏覽:398
數控編程代表 發布:2025-02-13 05:58:51 瀏覽:385
編程凸輪 發布:2025-02-13 05:38:21 瀏覽:691
判斷素數的編程 發布:2025-02-13 05:29:25 瀏覽:618
androidaes加密 發布:2025-02-13 05:08:36 瀏覽:493