网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

android开发中使用okhttp上传文件到服务器-创新互联

开发android手机客户端,常常会需要上传文件到服务器,比如:你手机里的照片。

为嵩县等地区用户提供了全套网页设计制作服务,及嵩县网站建设行业解决方案。主营业务为成都做网站、成都网站制作、嵩县网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

使用okhttp会是一个很好的选择。它使用很简单,而且运行效率也很高。

首先,在 app/build.gradle 的 dependencies 增加 implementation 'com.squareup.okhttp3:okhttp:3.8.1' 可以参照如下代码

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
  compileSdkVersion 26
  defaultConfig {
    applicationId "com.cofox.mykt.myweather"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
  sourceSets {
    main {
      res.srcDirs =
          [
              'src/main/res/layout/menufunction',
              'src/main/res'
          ]
    }
  }
}
dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
  implementation 'com.android.support:appcompat-v7:26.1.0'  implementation 'com.android.support.constraint:constraint-layout:1.0.2'
  testImplementation 'junit:junit:4.12'  androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  implementation 'org.jetbrains.anko:anko-sdk19:0.10.3'
  implementation 'org.jetbrains.anko:anko-support-v4:0.10.3'
  implementation 'org.jetbrains.anko:anko-appcompat-v7:0.10.3'
  implementation 'com.google.code.gson:gson:2.7'
implementation 'com.android.support:percent:26.1.0'
  implementation 'com.squareup.okhttp3:okhttp:3.8.1'
}

新闻名称:android开发中使用okhttp上传文件到服务器-创新互联
分享路径:http://bjjierui.cn/article/pgjpd.html

其他资讯