Android Quickstart
Quickstart: Implementing Particle Connect within Android Applications
Particle Network has support for Android (Kotlin) through various platform-native SDKs. Getting started only takes a few steps.
This document covers everything needed to get up and running with Particle Connect on Android in just a few minutes.
For complete documentation covering the implementation of Particle Connect on Android in more depth, head over to the Android SDK reference.
Before getting started, there are a few prerequisites to keep in mind; the instructions following may not work correctly if your project doesn’t meet these requirements.
Prerequisites
- minSdkVersion 23 or higher.
- compileSdkVersion, targetSdkVersion 34 or higher.
- JavaVersion 17.
- Jetpack (AndroidX).
- Android Gradle Plugin Version 8.5.1 or higher.
- Gradle Version 8.9 or higher.
Configuring settings.gradle
To begin, you’ll need to ensure your settings.gradle
file is structured/configured to use Maven; below is an example of how this file should look.
Configuring the Particle dashboard
Before continuing to the configuration of build.gradle
, we’ll need to first retrieve three key values from the Particle dashboard.
These values include your: projectId
, clientKey
, and appId
. Using these keys, you’ll be able to link your instance of Particle Connect with a project configured on the dashboard.
To retrieve these, follow the below steps.
For more information on the Particle dashboard, take a look at this video or visit the dashboard quickstart.
Configuring build.gradle
With your project keys retrieved, you’re ready to configure Particle through your build.gradle
file. Here, you’ll establish the various SDKs used within your application and plug in the aforementioned keys.
Specifically, you’ll need the following libraries:
network.particle:connect
network.particle:connect-kit
network.particle:connect-auth-core-adapter
network.particle:api-service
network.particle:connect-evm-adapter
, for onboarding via EVM private key. (not recommended)network.particle:connect-solana-adapter
, for onboarding via Solana private key. (not recommended)network.particle:connect-phantom-adapter
, if using Phantom.network.particle:connect-wallet-connect-adapter
,network.particle:wallet-service
, if you’d like to use Particle’s embedded wallet interface.network.particle:aa-service
, if you’d like to use ERC-4337 account abstraction.
All in all, your build.gradle
file should look similar to the following (replace the placeholder values with the previously retrieved keys and proper SDK versions).
Configuring AndroidManifest.xml
With your build.gradle
file ready to go, the final point of configuration needed is within AndroidManifest.xml
, in which you’ll have to insert the previously retrieved project keys once again.
Below is an example of this file with areas in which project keys are needed highlighted.
Initializing Particle Connect
Finally, with your project configured (settings.gradle
, build.gradle
, and AndroidManifest.xml
), it’s time to initialize Particle Connect within your application.
This is done through ParticleConnect.init
, which takes the following parameters:
application
, which represents the underlying Android application.env
, eitherenv.PRODUCTION
,env.DEV
, orenv.STAGING
; this alters the information logged when running the application.chain
, aChainInfo
object (fromnetwork.particle.chains.ChainInfo.Companion.{chain}
) that represents the primary chain you intend to use.dAppData
, metadata for your application to be used with WalletConnect.createAdapters
, a list of wallets (adapters imported fromcom.wallet.connect.adapter.{Adapter}
) that you’d like to support within your application.
An example of a complete call to ParticleConnect.init
has been included below.
Opening connection modal
The connection modal provided by Particle Connect (including both wallets defined through the aforementioned list of adapters alongside social logins) can be opened now that the SDK has been initialized.
Opening the modal is as simple as defining the various social logins you’d like to be supported alongside the wallets being used and their order; this is handled through ParticleConnectKit.connect
, passing an instance of ConnectKitConfig
, as exemplified below.
Examples of Utilization
Retrieve User Information
Upon a successful connection, you’ll be able to retrieve information about the resulting account through two mechanisms. The first involves reading properties on the object originally assigned to the ParticleConnectKit.connect
call, which will contain core properties such as publicAddress
after an account is loaded.
Additionally, to explicitly retrieve detailed information, you can call AuthCore.getUserInfo
, which will return a userInfo
object with various properties detailing the connection method used, addresses, and so on (to learn more about the structure of this object, head over to its API reference).
Send a Transaction
Transactions can be constructed and sent directly through the SDK; below is an example of the standard flow here.
In essense, you’ll need to generate a transaction object with ParticleNetwork.evm.createTransaction
(or the solana
equivalent), passing in standard parameters such as from
, to
, value
, and (if you’re interacting with a contract) data
. Using these, an object will be returned which can be used directly for execution.
Execution needs to be initiated through an instance of the active connector, or adapter (the method in which a user connected); this can be retrieved and loaded using ParticleConnect.getAdapters
, as demonstrated below. Upon loading the adapter, you can simply call {adapter}.signAndSendTransaction
, passing in the previously generated transaction object. Upon doing so, the user will be prompted to confirm the transaction.
Was this page helpful?