一、

传键值对

    public String webLogin() {
String responseData = null;
OkHttpClient client = new OkHttpClient();
TextView tvUser = findViewById(R.id.EditTextUser);
TextView tvPassWord = findViewById(R.id.EditTextPassWord);
String user = tvUser.getText().toString();
String passWord = tvPassWord.getText().toString();  
RequestBody body = new FormBody.Builder().add("User", user).add("PassWord", passWord).build();
//请求
Request request = new Request.Builder().addHeader("Content-Type","application/json;charset=utf-8").url("网址").post(body).build();
try {
Response response = client.newCall(request).execute();
responseData = response.body().string();
} catch (IOException e) {
e.printStackTrace();
}
return responseData;
}

二、

传字符串

android okhttp3的更多相关文章

  1. 【转】Android OkHttp3简介和使用详解

    一 OKHttp简介 OKHttp是一个处理网络请求的开源项目,Android 当前最火热网络框架,由移动支付Square公司贡献,用于替代HttpUrlConnection和Apache HttpC ...

  2. Android OkHttp3简介和使用详解

    一 OKHttp简介 OKHttp是一个处理网络请求的开源项目,Android 当前最火热网络框架,由移动支付Square公司贡献,用于替代HttpUrlConnection和Apache HttpC ...

  3. OkHttp3源码详解(三) 拦截器-RetryAndFollowUpInterceptor

    最大恢复追逐次数: ; 处理的业务: 实例化StreamAllocation,初始化一个Socket连接对象,获取到输入/输出流()基于Okio 开启循环,执行下一个调用链(拦截器),等待返回结果(R ...

  4. 基本使用——OkHttp3详细使用教程

    基本使用——OkHttp3详细使用教程 转 https://blog.csdn.net/xx326664162/article/details/77714126 概述 OkHttp现在应该算是最火的H ...

  5. Retrofit 2.0 超能实践(一),okHttp完美支持Https传输

    http: //blog.csdn.net/sk719887916/article/details/51597816 Tamic首发 前阵子看到圈子里Retrofit 2.0,RxJava(Andro ...

  6. Retrofit 2.0 超能实践,完美支持Https传输

    http://blog.csdn.NET/sk719887916/article/details/51597816 前阵子看到圈子里Retrofit 2.0,RxJava(Android), OkHt ...

  7. 【HTTP】402- 深入理解http2.0协议,看这篇就够了!

    本文字数:3825字 预计阅读时间:20分钟 导读 http2.0是一种安全高效的下一代http传输协议.安全是因为http2.0建立在https协议的基础上,高效是因为它是通过二进制分帧来进行数据传 ...

  8. Android网络框架---OkHttp3

    1.添加依赖 compile 'com.squareup.okhttp3:okhttp:3.4.2' project Structure-->dependencied/搜索okhttp. com ...

  9. [Android] Android RxJava2+Retrofit2+OkHttp3 的使用(一) --基础篇 Retrofit2 的使用

    本文是 Android RxJava2+Retrofit2+OkHttp3 的使用(一) --基础篇 Retrofit2 的使用 本文的目标是用 Retrofit写一个网络请求: 本文以从获取天气预报 ...

随机推荐

  1. CenOS 配置C/C++语言

    1.下载eclipse+CDT组合包. 2.电脑上安装GCC, G++ 3.在eclipse上创建一个C++ project 4. Eclipse CDT功能很强大,安装完虽然可以编译运行c++程序, ...

  2. b树的实现

    花了蛮长时间实现的b树插入操作.有时间再实现其他操作. #include <stdio.h> #include <stdlib.h> #define M 5 enum KeyS ...

  3. Javascript 属性高级写法

    http://www.cnblogs.com/YuanSong/p/3899287.html

  4. 【Spiral Matrix】cpp

    题目: Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spira ...

  5. window.parent 、window.top及window.self 详解

    在应用有frameset或者iframe的页面时,parent是父窗口,top是最顶级父窗口(有的窗口中套了好几层frameset或者iframe),self是当前窗口. 1. window.self ...

  6. day06_06 字典操作01

    1.0 字典操作 dic1 = {'name':'alex'} dic1['age'] = 18 print(dic1) #>>>{'age': 18, 'name': 'alex' ...

  7. hdu 2579 Dating with girls(2) (bfs)

    Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  8. BZOJ4300 绝世好题 【dp】

    题目 给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi&bi-1!=0(2<=i<=len). 输入格式 输入文件共2行. 第一行包括一个整数n. 第二行包括n个 ...

  9. 《c程序设计语言》读书笔记-4.12-递归整数转字符串

    #include <stdio.h> #include <math.h> #include <stdlib.h> void itoa_num(int n, char ...

  10. spring in action 学习笔记六:bean在不同情况下的默认id号或者将名字

    bean如果不知名id是什么它一般都有一个id或者讲名字. 第一种情况:组件扫描的情况:默认的id号或者bean的name是类名的首字母小写. 代码如下: package com.qls.beanli ...