2.2 SDK Initialization Configuration
2.2.1 Initialization
We recommend that you download and experience the HiSavana Demo to gain a more intuitive and in-depth understanding of the SDK's features and usage. Through the Demo, you can quickly get started and explore its application in real-world scenarios.
Initialization example code:
public class DemoApplication extends Application {
@Override
public void onCreate() {
super.onCreate()
/**
* 'Multi-process and WebView scenarios' require setting different data directories for WebView, reason:
* After Android P(9.0), to enhance security and avoid conflicts between WebView instances in different processes,
* Google introduced a new restriction: WebView instances in different processes are not allowed to use the same data directory.
*
* Solution:
* To avoid this issue, it is recommended to specify a unique directory for WebView instances in each process
* in the Application's onCreate() method and before SDK initialization.
*
* Example:
* // Set a unique suffix for each process
* WebView.setDataDirectorySuffix(processName);
*/
AdManager.init(context,new AdManager.AdConfigBuilder()
// Required, appId is used to identify the apk identity. Only recognized identities will receive ad resources.
.setAppId("appId")
// Optional, required if enabling built-in ad functionality. Value is the version number of the zip package (provided by operations, unit: Long), used for fallback ad updates
.setInternalDefaultAdVersion(1710853164130L)
// Optional, whether to enable image loading resource competition optimization (only effective when using Glide image loading library and for Splash, Interstitial, Reward ad units). Enable set to true, disable set to false, default is disabled
.setShouldOptimizeImageLoading(true)
// Optional. Controls the toast prompt for the new interstitial and rewarded ad styles after reward completion; true: enabled, false: disabled, default is true.
.setRewardedCompletionToastEnabled(true)
// Optional, whether to print ad logs, default is false. Keywords: ADSDK_S, ADSDK_N
.setDebug(false)
// Optional, whether to request test ads, when set to true the requested ads will be test ads, default is false.
.testRequest(false)
// Optional, whether currently running monkey tests, default is false. Recommended to set to true during testing, set to false in production environment.
.setMonkey(false)
.build());
}
}
Reminder: The appId here is the hisavana appId, a parameter provided by operations (needs to be applied for from advertising Operations Personnel). In the official release version, setDebug and testRequest must not be true.
2.2.2 Test Process
- Apply to hisavana for test app id and related ad unit ids.
- When testing hisavana ads, set testRequest to true.
- After testing is completed, set testRequest to false, and the official release version can be published.