Android中实现下载URL地址的网络资源的实例分享

2019-12-10 18:12:15于海丽

 

<LinearLayout xmlns:android="http://www.easck.com/apk/res/android" 
  xmlns:tools="http://www.easck.com/tools" 
  android:layout_width="match_parent" 
  android:layout_height="match_parent" 
  android:orientation="vertical" 
  tools:context=".MainActivity" > 
 
  <EditText 
    android:id="@+id/url" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="http://www.easck.com/svn/m2-repo/com/google/code/ksoap2-android/ksoap2-android-assembly/3.1.0/ksoap2-android-assembly-3.1.0-jar-with-dependencies.jar" /> 
 
  <EditText 
    android:id="@+id/target" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"  
    android:text="/mnt/sdcard/"/> 
 
  <Button 
    android:id="@+id/downBn" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="down" /> 
 
  <ProgressBar 
    android:id="@+id/br" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 
 
</LinearLayout> 

<!-- 在SD卡中创建与删除文件的权限 --> 
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> 
<!-- 在SD开中写入数据的权限 --> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<!-- 访问网路的权限 --> 
<uses-permission android:name="android.permission.INTERNET" /> 


注:相关教程知识阅读请移步到Android开发频道。