代码一样没有请求数据,用的是retrofit2.9.0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | RestClient .builder() .url( "index.php" ) // .params("", "") .success( new ISuccess() { @Override public void onSuccess(String response) { Toast.makeText(getBaseContext(), response, Toast.LENGTH_LONG).show(); Log.e(TAG, "onSuccess: " + response); } }) .build() .get(); |
33
收起
正在回答 回答被采纳积分+1
4回答
qq_格式化过去_2
2020-12-18 17:51:03
试着在application节点里添加
android:usesCleartextTraffic="true"
这句话,可以允许明文网络请求,也就是http的请求,我已经用了,可以的,下面贴出代码
1 | <application<br> android:name= ".MallExampleApp" <br> android:allowBackup= "true" <br> android:icon= "@mipmap/ic_launcher" <br> android:label= "@string/app_name" <br> android:roundIcon= "@mipmap/ic_launcher_round" <br> android:supportsRtl= "true" <br> android:usesCleartextTraffic= "true" <br> android:theme= "@style/Theme.Mallkotlinexample" ><br> <activity android:name= ".MainActivity" ><br> <intent-filter><br> <action android:name= "android.intent.action.MAIN" /><br><br> <category android:name= "android.intent.category.LAUNCHER" /><br> </intent-filter><br> </activity><br></application><br> |
Charles_King_
2020-08-20 06:06:01
没有走进onSuccess方法里面
3.Android 高级应用与Kotlin综合实战
- 参与学习 人
- 提交作业 116 份
- 解答问题 1012 个
本阶段是提升项目经验的必备,除Android开发的高级控件,还有Android官方大力推荐的开发语言Kotlin,未来Android发展的方向,最后使用Kotlin来开发热门电商项目。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧