目录

Prepare a Huawei phone running HMS Core (APK) 2.6.5 or later. After completing the above install referrer service code, you can compile the code. If an error occurs during the compilation, modify the code as prompted. After the compilation is complete, an .apk file is generated and installed.

1. Generating Install Referrer Information

Install referrer information can be obtained only after an ad is delivered on HUAWEI Ads. A demo is provided here to generate install referrer information on the device for you to test your app. For details about the demo download address, please refer to Sample Code.

Notice:
Only the project with the com.huawei.pps.hms.test package can be used to test the function of obtaining install referrer information.

2. Modifying Your App for the Testing

2.1 SDK Mode

When creating InstallReferrerClient, set the test mode by calling setTest(true), as shown below:

  1. mReferrerClient = InstallReferrerClient.newBuilder(mContext).setTest(true).build();
  2. mReferrerClient.startConnection(installReferrerStateListener);
Notice:
setTest(true) is used only for testing. For an official release, use setTest(false).

2.2 AIDL Mode

During the testing, set the name of the bound AIDL service package to com.huawei.pps.hms.test, as shown below:

  1. mServiceConnection = new InstallReferrerServiceConnection();
  2. Intent intent = new Intent("com.huawei.android.hms.CHANNEL_SERVICE");
  3. intent.setPackage("com.huawei.pps.hms.test");
  4. boolean result = mContext.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
  5. Log.i(TAG, "bindService result: " + result);
Notice:
The package name com.huawei.pps.hms.test is used only for testing. For an official release, use the package name com.huawei.hwid.

3. Verifying the Install Referrer Capability

If logs show that the install referrer information has been correctly obtained, your app has correctly integrated the install referrer capability.