标签:over post utils cli des 问题 roi androidor https
https://blog.csdn.net/honghailiang888/article/details/54289632?utm_source=blogxgwz6
参照Android Retrofit2.1.0设置编码格式GBK 的文章。
OkHttpClient.Builder builder = new OkHttpClient().newBuilder(); /***lyl TODO 下面一行代码加入https的接口访问**/ //builder.sslSocketFactory(getSSLSocketFactory(context)); builder.addInterceptor(new Interceptor() { @Override public Response intercept(Interceptor.Chain chain) throws IOException { Request original = chain.request(); // Request customization: add request headers // Log.d(TAG, fdata);StringUtil.encryptAsDoNet(fdata, 1) // Log.d(TAG, "加密后:"+DESUtils.encryptAsDoNet(fdata, 1)); Request.Builder requestBuilder = null; try { requestBuilder = original.newBuilder() .addHeader("androidorios", "android"); } catch (Exception e) { LogUtil.e(TAG,"---create--addhead---"+e.toString()); } Request request = requestBuilder.build(); request = requestBuilder.post(RequestBody.create(MediaType.parse("application/x-www-form-urlencoded;charset=utf-8"), URLDecoder.decode(bodyToString(request.body()), "UTF-8"))) .build(); return chain.proceed(request); } });
就可以解决问题。
Retrofit 打印log时,中文会显示类似%E8%BE%BD字符
标签:over post utils cli des 问题 roi androidor https
原文地址:https://www.cnblogs.com/liyanli-mu640065/p/9875282.html