七牛云上传图片闪退的问题,增加网络配置Http可以请求

This commit is contained in:
老皮 2024-11-04 14:46:55 +08:00
parent d2f508699c
commit 5330e2d884
3 changed files with 23 additions and 1 deletions

View File

@ -104,6 +104,7 @@
</queries> </queries>
<application <application
android:networkSecurityConfig="@xml/network_security_config"
android:name="com.shayu.phonelive.AppContext" android:name="com.shayu.phonelive.AppContext"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/new_logo" android:icon="@mipmap/new_logo"

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">upload-z0.qiniup.com</domain>
</domain-config>
</network-security-config>

View File

@ -54,14 +54,29 @@ public class UploadQnImpl implements UploadStrategy {
public void complete(String key, ResponseInfo info, JSONObject response) { public void complete(String key, ResponseInfo info, JSONObject response) {
System.out.println("UploadQnImpl 上传-----ok----> " + info.isOK() + "--key---> " + "---response---> " + (response != null ? response.toString() : null)); System.out.println("UploadQnImpl 上传-----ok----> " + info.isOK() + "--key---> " + "---response---> " + (response != null ? response.toString() : null));
//L.e("UploadQnImpl 上传-----ok----> " + info.isOK() + "--key---> " + "---response---> " + (response != null ? response.toString() : null)); //L.e("UploadQnImpl 上传-----ok----> " + info.isOK() + "--key---> " + "---response---> " + (response != null ? response.toString() : null));
try { /* try {
assert response != null; assert response != null;
mList.get(mIndex).setRemoteAccessUrl(response.getString("key")); mList.get(mIndex).setRemoteAccessUrl(response.getString("key"));
} catch (JSONException e) { } catch (JSONException e) {
// throw new RuntimeException(e); // throw new RuntimeException(e);
L.e(e); L.e(e);
return; return;
}*/
if (response == null) {
// Handle the null case, e.g., log an error, throw a specific exception, etc.
L.e("Response is null");
return;
} }
try {
mList.get(mIndex).setRemoteAccessUrl(response.getString("key"));
} catch (JSONException e) {
L.e(e);
return;
}
if (mList == null || mList.size() == 0) { if (mList == null || mList.size() == 0) {
if (mUploadCallback != null) { if (mUploadCallback != null) {
mUploadCallback.onFinish(mList, false); mUploadCallback.onFinish(mList, false);