2.2 SDK initialization configuration
2.2.1 Initialization
Initialization sample code:
public class DemoApplication extends Application {
@Override
public void onCreate() {
super.onCreate()
/**
* 'Multi-process and WebView scenario' requires setting different data directories for WebView, for the following reasons:
* Android P (9.0) and later, in order to enhance security and avoid conflicts between WebView instances between different processes,
* Google has introduced a new restriction: WebView instances in different processes are not allowed to use the same data directory.
*
* Solution:
* In order to avoid this problem, it is recommended that in Application is onCreate() and before the SDK is initialized,
* Specify a unique directory for each WebView instance in the process.
*
* Example:
* // Set a unique suffix for each process
* WebView.setDataDirectorySuffix(processName);
*/
AdManager.init(context,new AdManager.AdConfigBuilder()
// Must be set, appId is used to identify the apk identity, only the identified identity will have advertising resources returned
.setAppId("appId")
// Optional, if the built-in advertising function needs to be set, the value is the version number of the zip package (provided by the operation, unit: Long), used for updating the cover-up advertising
.setInternalDefaultAdVersion(1710853164130L)
// Optional, whether to enable the image loading resource competition optimization function (only effective when using the Glide image loading library and the code position is Splash, Interstitial, Reward). Enable is set to true, disable is set to false, and is disabled by default
.setShouldOptimizeImageLoading(true)
// Optional, whether to print advertising logs, the default is false. Keywords: ADSDK_S, ADSDK_N
.setDebug(false)
// Optional, whether to request test ads. When set to true, the requested ads are test ads. The default is false
.testRequest(false)
// Optional, whether the monkey test is currently running. The default is false. It is recommended to set it to true during testing and to false in the official environment
.setMonkey(false)
.build());
}
}
Reminder: The appId here is hisavana's appId, parameters provided by the operator (you need to apply to the advertising Operating Personnel). In the officially launched version, setDebug and testRequest cannot be true.
2.2.2 Test Process
- Apply to hisavana for the app ID of the test and the relevant advertising space ID.
- Test the advertisement of hisavana, and set testRequest to true.
- After the test, set testRequest to false to release the official online version.