Adding Discover SDK to your Android Project
Use the Discover Android SDK to instrument your native Android applications for logging and analysis. The Android SDK implementation is simple. It uses standard Android classes and user interface controls to track user interface events.
Before you begin
- Install Android Studio
- Use Gradle version 7.2
Adding the SDK to your Project
About this task
Procedure
- Add the DCXCore.jar and DiscoverMod.jar into the libs folder of your application to make the capture functions available.
- Add the files into the build path of the application you want to instrument.
-
Integrate Discover SDK files into your Android project by copying the
following Discover SDK files to the specified folder for your Android
project.
Filename Android Project Loacation DiscoverBasicConfig.properties assets folder DiscoverAdvancedConfig.json assets folder DiscoverLayoutConfig.json assets folder DCXCoreBasicConfig.properties assets folder DCXCoreAdvancedConfig.json assets folder discovermod.jar libs folder dcxcore.jar libs folder -
Add permissions for Android:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> -
Write
Singletonclass. It should extendApplicationclass, and this class should declared in maniesfest.xml within theApplicationtag.android:name=".MyApplication" public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); new Discover(this); Discover.enable(); Discover.startSession(); Log.e("sessionID", Discover.getCurrentSessionId()); } @Override public void onLowMemory() { Discover.onLowMemory(); super.onLowMemory(); } @Override public void onTerminate() { Discover.disable(); super.onTerminate(); } } -
Update each Activity class and override the
dispatchTouchEventmethod:public boolean dispatchTouchEvent(MotionEvent e) { Discover.dispatchTouchEvent(this, e); return super.dispatchTouchEvent(e); }
Recording an Activity
About this task
Procedure
-
You can record an activity displayed by placing the following information
in the
OnCreatemethod:// this will indicate logical page name. Discover.logScreenview(activity, "Name", ScreenviewType.LOAD); // this will get layout of page after it being created. Discover.logScreenLayoutOnCreate(activity, "Name"); - Post the data from the app to the endpoint by adding the post URL in .
-
To take screenshot, change the values for params in
HCLGlobalScreenSettingsdictionary as shown in the following example:assets -> DiscoverLayoutConfig: "takeScreenShot": true -
To blur the screenshot, complete the following steps:
-
To take screenshots with different blur values for different screens,
complete the following steps:
-
To take screenshots without blur, pass
screenShotBlurvalue as 0 inHCLGlobalScreenSettings. No code changes are needed in the Activity or screens. This will create screenshots without blur.