Setup SDK
Flutter_Android PcketSDK Integration Guide
Overview
This guide is intended for application developers who want to monetize their Android apps using the Packet SDK. Packet SDK supports Android native apps written in Java and Kotlin.
Integrating the Packet SDK into your app is the first step to earning revenue. Once integrated, you'll start seeing revenue in the Packet SDK dashboard within 24 hours.
This document will walk you through the steps required for proper integration. Most apps can be integrated with the Packet SDK in about 15 to 20 minutes.
Compatibility Information
System
Supports ARMv7 and ARMv8 architectures; compatible with Android 5.0 and above
Development Environment
Recommended to use Android Studio for development
Preparation
Apply for appkey
Register and log in to the PacketSDK ,go to Dashboard>APP to add your app and get your appkey
SDK Integration Package Directory Structure
After completing the previous step, download the Android SDK package flutter_android_sdk.zip.
Unzip the SDK package to find the following files:
├── Flutter_SDK_Demo.zip A demo app with the SDK already integrated. You can use this demo to understand how to integrate the SDK. Make sure to test the demo first to understand how the SDK works.
├── libs
│ └── packet_sdk_flutter_v*.aar** The obfuscated AAR file.
Installation
Copy packet_sdk_flutter_v*.aar** to the libs directory of your android project.
Add dependencies for the required plugins in the pubspec.yaml file of the project.
Run the "flutter pub get" command to ensure that the plugin is downloaded and installed correctly into the project.
Example files structure:
SDK setup
SDK requires internet connectivity to work. To allow your app to use internet connection add following permission to AndroidManifest.xml file.
Configure SDK settings right after initializing the SDK, but before calling the PacketSdk.start() function.
Stop SDK
Call PacketSdk.stop() in order to stop SDK.
Withdraw the consent
User should be able to opt out from using SDK at any time. When user does so within your app, you should call PacketSdk.optOut() function, which will immediately stop SDK and will no longer start it unless user grants consent again.
Running in background
If you want to keep SDK running in background when app is closed, you need to take some additional steps. A few additional FOREGROUND_SERVICE permission are required. Add them to your AndroidManifest.xml
Then let SDK know that you want to allow it to run in the background.
Custom consent window
If default SDK consent window doesn't suit your needs, you can create a custom consent window. Make sure to call PacketSdk.optIn() whenever user gives a consent and PacketSdk.optOut() whenever user declines it.
Logging
Call PacketSdk.setEnableLogging(true) in order to enable logging to logcat.
Status monitor
Allows to set listener to monitor sdk status.
SDK API
Status Value Description
100
Starting...
101
Get server fail.
102
Connect fail.
200
Connect success.
Once you've received connect success. in the callback function, you will start seeing devices data and revenue in PacketSDK Dashboard in 24 hours.
Last updated