There is a problem in the company’s project today, some mobile phone loaded pictures can be displayed, and some mobile phone loaded pictures cannot be displayed. After checking, it is found that all mobile phones that cannot display pictures are 9.0 mobile phones. An attribute has been added to the application of Androidmanifest.xml according to the ideas on the Internet, namely: Android: usesCleartextTraffic = “true”, the test can, according to the specific reason is: “” “in Android9.0 machine, the default does not support HTTP access, all network access must use HTTPS “.

The application in androidmanifest.xml is as follows:

<application 
android:allowBackup="true" 
android:icon="@mipmap/ic_icon" 
android:label="@string/app_name" 
android:roundIcon="@mipmap/ic_icon" 
android:supportsRtl="true" 
android:usesCleartextTraffic="true" 
android:theme="@style/diCheGouTheme">
Copy the code

But I found that some pictures or 9.0 system can show, and did not set the android: usesCleartextTraffic = “true” attribute, comparison and found that the display image using the context of the global context, namely: DcgApp. GetAppContex T (), the specific reason is unknown.

So there are two ways to solve this problem.