版本更新
来源:互联网 发布:蜂鸟众包网络异常 编辑:程序博客网 时间:2024/06/07 07:16
public class MainActivity extends Activity {
private String url="http://www.oschina.net/uploads/osc-android-v2.6.4-release.apk";
private String sdPath = "/sdcard/" + System.currentTimeMillis() + "yuyin.apk";
private Button mBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBtn = (Button) findViewById(R.id.btn);
}
public void btn(View v){
HttpUtils httpUtils=new HttpUtils();
httpUtils.download(url, sdPath, true, new RequestCallBack<File>() {
@Override
public void onSuccess(ResponseInfo<File> arg0) {
mBtn.setText("下载完成");
//路径
String path = arg0.result.getPath();
File file = new File(path);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
startActivity(intent);
}
@Override
public void onFailure(HttpException arg0, String arg1) {
mBtn.setText("下载失败");
}
@Override
public void onLoading(long total, long current, boolean isUploading) {
// TODO Auto-generated method stub
super.onLoading(total, current, isUploading);
mBtn.setText("正在下载.....");
ProgressDialog dialog=new ProgressDialog(MainActivity.this);
dialog.setTitle("正在下载....");
dialog.setMax((int) total);
dialog.setProgress((int) current);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
}
@Override
public void onStart() {
super.onStart();
mBtn.setText("开始下载");
}
});
}
}
0 0
- 版本更新
- //版本更新
- 版本更新
- 更新版本
- 版本更新
- 版本更新
- 版本更新
- 版本更新
- 版本更新
- 版本更新
- 版本更新
- 版本更新
- 版本更新
- 版本更新
- 版本更新
- 版本更新
- 版本更新
- 版本更新
- linux常用命令
- 导入证书到jdk
- Bitmap.createScaledBitmap的陷阱
- spring 依赖注入
- RSA算法加密/解密工具类
- 版本更新
- MySQL修改表的外键约束
- 线程(4)——JAVA中的基本线程操作(下)
- Servlet线程安全问题
- 相关系数 Correlation Coefficient 的理解
- 抽象类 abstract class
- hdu5326 树形dp
- 清除CMOS方法大全
- google构建工程的工具集