導航:首頁 > 文件教程 > android文件下載進度

android文件下載進度

發布時間:2023-06-06 07:03:48

1. 誰知道怎樣在安卓手機通知欄里顯示下載進度條啊

通知欄顯示所用到的布局文件content_view.xml

主運行類:

packageyyy.testandroid4;

importjava.util.Timer;

importjava.util.TimerTask;

importandroid.app.Activity;

importandroid.app.AlertDialog.Builder;

importandroid.app.Notification;

importandroid.app.NotificationManager;

importandroid.app.PendingIntent;

importandroid.content.DialogInterface;

importandroid.content.Intent;

importandroid.content.pm.PackageManager.NameNotFoundException;

importandroid.os.Bundle;

importandroid.os.Handler;

importandroid.os.Message;

importandroid.view.View;

importandroid.view.View.OnClickListener;

importandroid.widget.Button;

importandroid.widget.RemoteViews;

importandroid.widget.Toast;

{

privateHandlerhandler=newHandler(){

@Override

publicvoidhandleMessage(Messagemsg){

//TODOAuto-generatedmethodstub

super.handleMessage(msg);

switch(msg.what){

case0:

notif.contentView.setTextViewText(R.id.content_view_text1,len+"%");

notif.contentView.setProgressBar(R.id.content_view_progress,100,len,false);

manager.notify(0,notif);

break;

case1:

Toast.makeText(TestAndroid4Activity.this,"下載完成",0).show();

break;

default:

break;

}

}

};

privateButtonupdate,cancel;

privateintlocalVersion,serverVersion;

privateintlen;

;

privateNotificationnotif;

/**.*/

@Override

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

update=(Button)findViewById(R.id.update);

update.setOnClickListener(newOnClickListener(){

@Override

publicvoidonClick(Viewarg0){

//TODOAuto-generatedmethodstub

//點擊通知欄後打開的activity

Intentintent=newIntent(TestAndroid4Activity.this,OtherActivity.class);

PendingIntentpIntent=PendingIntent.getActivity(TestAndroid4Activity.this,0,intent,0);

manager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);

notif=newNotification();

notif.icon=R.drawable.logo;

notif.tickerText="新通知";

//通知欄顯示所用到的布局文件

notif.contentView=newRemoteViews(getPackageName(),R.layout.content_view);

notif.contentIntent=pIntent;

manager.notify(0,notif);

newDownLoadThread().start();

}

});

}

}

{

privateTimertimer=newTimer();

@Override

publicvoidrun(){

//TODOAuto-generatedmethodstub

super.run();

timer.schele(newTimerTask(){

@Override

publicvoidrun(){

//TODOAuto-generatedmethodstub

Messagemsg=newMessage();

msg.what=0;

msg.obj=len;

handler.sendMessage(msg);

if(len==100){

timer.cancel();

handler.sendEmptyMessage(1);

}

}

},0,1000);

len=0;

try{

while(len<100){

len++;

Thread.sleep(1000);

}

}catch(InterruptedExceptione){

//TODOAuto-generatedcatchblock

e.printStackTrace();

}

}

}

}

2. android studio 一打開項目下方就又有個下載進度條,每次打開都要下載,怎麼回事啊

如果是第一次導入的項目,她會去網路倉庫下載你build.gride里導入的包比如http請求的,或者第三方組件的包。會有各種類似下載的進度條。之後打開都是檢查版本什麼的,還有初始化項目,也會耗費一定的時間

閱讀全文

與android文件下載進度相關的資料

熱點內容
蘋果6進水讀不了卡什麼原因 瀏覽:68
網盤文件怎麼提取到筆記軟體里 瀏覽:136
java解析簡單json數據類型 瀏覽:750
008神器破解版使用教程 瀏覽:974
word2007密碼設置 瀏覽:593
iPhone5解鎖密碼格圖案 瀏覽:392
微信文件怎麼填 瀏覽:87
燕十八老師精通mysql視頻教程 瀏覽:255
汽車保養數據怎麼清 瀏覽:629
pdf文件圖像打不開 瀏覽:176
msp430時鍾程序 瀏覽:660
查看sd卡文件系統格式 瀏覽:696
c盤中顯示隱藏文件 瀏覽:951
蘋果升級系統白屏 瀏覽:136
三菱gxplc編程軟體如何使用 瀏覽:710
海康威視手機app怎麼看不了 瀏覽:482
wordpress下載中心插件 瀏覽:402
微信限制字數是多少 瀏覽:20
策劃輸出主要從哪些文件來 瀏覽:174
網路營銷找什麼工作 瀏覽:372

友情鏈接