At a glance: Learn how to use and configure the Android sample app to quickly integrate and test the AppsFlyer Android SDK.
For Android Version 4.8.7
The Android sample app was developed using the Android Studio environment.
The AppsFlyer sample app enables you to see how our newest SDK is integrated into a working project.
You can use this project as a reference to your own project to verify and debug the integration process. In addition, you can use the sample app to run end-to-end test scenarios and review the results in your dashboard, such as reports and Push API.
For your convenience, the project contains instructions in the comments under the tag: AppsFlyer.
Using the sample app for testing
The following sections are covered in this guide:
- Using the sample app
- Customizing your Sample app
- Deep linking
You can use this project to test the functionality of the SDK and view changes made in your AppsFlyer dashboard.
Follow these instructions to link the project to your AppsFlyer account:
- Open the project using Android Studio
- Change the package name to match the name configured in your AppsFlyer dashboard (your new package name must be unique). Make sure your new package name appears in all references throughout the project (Make sure the same name appears in build.gradle).
- Under the Java directory, open the Java file MainActivity.java. You can find the method located in onCreate.
(Replace your_dev_key with the one listed under the SDK Integration section of your AppsFlyer dashboard.)
- Build the app to your test device. Make sure your test device is allowlisted in your AppsFlyer dashboard. See this article for more information.
Now you can test the sample app on your device and see the changes in your dashboard.
Be sure to use a custom generated AppsFlyer link when installing the app on your device, in order to receive a non-organic install.
Using the sample app
Once you have configured the project to be associated with your AppsFlyer account, you can open it and the following screen is displayed:
- Attribution Values: Displays the core values of your installation - You can see if you received a non-organic install after clicking a custom link, as well as your media source, click time (on your link) and install time (on your device).
- Track Event: Click this button to launch an event recording call which you can view in your dashboard (See Deep linking below for details of customization of this button).
Customizing your sample app
The sample app project contains a button to trigger a custom event recording call.
By default, this button is set to record a purchase event which can then be viewed in your dashboard as a revenue increase of $200.
To test different events, use the code from the MainActivity.java file, under the buttonOnClick method.
- To review all available event types you can record with the AppsFlyer SDK, see this article.
- In addition, under the registerConversionListener method, you can find several attribution parameters which are shown in a TextView. To view all available parameters, see this article.
Unpublished apps and parameters other than those printed in the default code of the sample app are returned as Null.
To edit your deep linking scheme:
- Go to the AndroidManifest file.
- Edit the <data> tags under <intent-filter>, inside Deep link <activity>.
- Generate a custom media source link using the AppsFlyer dashboard. See this article for guidance. (Be sure to include "&advertising_id=YOUR_
ADVERTISING_ID " in your link in order to receive a non-organic install.)
- Add the following tags to your link:
- If using only a scheme:
- If using a scheme and a host:
- If using only a scheme:
In your AndroidManifest file, you can view your custom deep linking schemes and hosts and change them as required. They are located under the <intent-filter> tab inside the Deep Link <activity> tab.
By default, you can test the deep linking in the sample app using the following links:
- For http://aftest.com—
- For aftest://—
Make sure the app is installed on your device before testing the deep links, as unpublished apps are not redirected to Google Play unless pre-installed.
Click one of the deep links, and you are redirected to the Deep Link activity (which cannot be accessed any other way).
- In Deep Link activity, you can also see the link you navigated from.
- By using the
sendDeepLinkDatamethod in the Deeplink.java file (located in
onCreate), you can attribute the deep linking to the corresponding media source.