Do not use the same WebView for multiple processes
1. Example: The program integrates aurora push, which triggers an H5 page jump in the notification push. When the jump calls a public WebActivity.
Because aurora push will start a separate process, the program will blink back with an error:
java.lang.RuntimeException: Using WebView from more than one process at once with the same data directory is not supported.
2. Solution: In the custom Appliaction class do the following:
public class MyApplication extends Application { @Override public void onCreate() { initPieWebView(); } private static final String PROCESS = "xxxxxx"; Private void initPieWebView() {if (build.version.sdk_int >= build.version_codes.p) {String processName = getProcessName(this); if (! PROCESS.equals(processName)) { WebView.setDataDirectorySuffix(processName); }}}}Copy the code
2. Https is used for data access by default
If an application running on 9.0 OS does not have Http adaptation, all Http cannot be accessed. There are two solutions to solve this problem.
1) Global shutdown check
2) Partial shutdown check, specific domain name shutdown check (need to be carefully checked, including third-party SDK)
Step 1: You need to configure the XML file on the Application node
<application android:networkSecurityConfig="@xml/network_security_config"> <! -... --> </application>Copy the code
The second step:
If checking is turned off globally, the network_security_config. XML file contains the following contents:
<? The XML version = "1.0" encoding = "utf-8"? > <network-security-config> <base-config cleartextTrafficPermitted="true"/> </network-security-config>Copy the code
If check is turned off locally, check is turned off for a specific domain name
<network-security-config> <domain-config cleartextTrafficPermitted="false"> <domain IncludeSubdomains ="true">http://www.baidu.com</domain> // domain </domain-config> </network-security-config>Copy the code
Remark:
1. If you don’t know much about the project you’re working on, just configure the big picture.
2. XML configuration syntax check the official documents for details
Developer. The android. Google. Cn/training/ar…
Change in Apache HTTP API usage
To continue using the Apache HTTP client, applications targeting Android 9 and later can add the following to their Androidmanifest.xml:
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
Copy the code
Note: Apps with a minimum SDK version 23 or lower require the Android: Required =”false” attribute because the org.apache.http. Legacy library is not available on devices with API level lower than 24. (On these devices, the Apache HTTP class is provided in BootClasspath.)