When integrating third-party SDKs into an Android app, deciding where to initialize them is crucial for proper functioning and maintainability.
- Initializing SDKs in the Application class is a common approach. The Application class is a singleton that exists throughout the app’s lifecycle.
- Advantages:
- Early Initialization: SDKs are initialized as soon as the app starts, ensuring they are available for the entire app.
- Centralized Control: You manage all SDKs in one place, making it easier to handle dependencies and configurations.
- Consistent Behavior: SDKs behave consistently across activities and fragments.
- Considerations:
- Performance: Initializing many SDKs can impact app startup time. Consider using asynchronous initialization or background threads.
- Order: Ensure proper initialization order, especially if SDKs have dependencies.
- Debug/Release Modes: Handle different versions for debug and release builds.
- Demonstrating and Testing a Singular SDK implementation using the Application Class.
- Invoking the Singular SDK from the Application Class to track Installs.
- Testing the handling of a Singular Link with Deferred Deep Linking (DDL).
- Testing the handling of a Singular Link with deep linking (DL).
- Triggering in-app events using Singular functions.
-
Clone the Repository:
-
Open the Project in Android Studio:
- Launch Android Studio.
- Choose "Open an existing Android Studio project."
- Navigate to the cloned repository and select the project folder.
- Install Dependencies:
- Ensure you have Kotlin and Android SDK installed.
- Set up any necessary environment variables or API keys.
- This project is using SDK key and Secret from the Singular Platform, referenced from the
local.propertiesfile.
- This project is using SDK key and Secret from the Singular Platform, referenced from the
- Add the dependencies from the Singular Android SDK Installation Guide: HERE
- Make sure you update the
AndroidManifest.xmlfile with the required permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="BIND_GET_INSTALL_REFERRER_SERVICE" />
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />- Add the Application Class name
android:name=".MyApplication"to theAndroidManifest.xmlfile. - Make sure you update the
AndroidManifest.xmlfile with the requiredintent-filterto support Singular Links:
<intent-filter>
<data android:scheme="YOUR_APP_SCHEME_HERE" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>- Build the Project:
- Click the "Build" button in Android Studio or run:
./gradlew build
- Run the App:
- Click the "Run" button (green triangle) in Android Studio.
- Choose an emulator or a connected device to run the app.
To examine the behavior of Singular Links, the deferred deeplink after a new install, or the deeplink if the app is already installed, follow the steps below.
- You will need a Singular Custom Link, configured for this app to perform the testing.
- Make sure the App is configured with the scheme on the Singular Apps Page Screenshot
- Send the Singular Link to an email account you can access from the Emulator.
-
Open the Android Emulator and make sure the App is Uninstalled.
-
Now, build the App from Android Studio to the Emulator. (This is simulating a User installing from the App Store)
-
When the App Opens, navigate to the
Logcatpane in Android Studio and review the Logs (Filter for the tag:Singular). From the output, you will see the Deferred Deeplink (DDL) logged from the Singular SDK Link Handler.
-
Now, background the app.
-
Navigate back to your email app and click the link again.
-
The App should open directly and the logcat output will display the deeplink provided from Singular.

-
Now, close the app.
-
Navigate back to your email app and click the link again.
-
The App should open directly and the logcat output will display the deeplink provided from Singular.

This testing illustrates the desired behavior of Singular Links.
Contributions are welcome! Please follow our contribution guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
