Android SDK
Getting Started
If you haven't already, please start with the Getting Started Guide below.
📄️ Getting Started
Developer Guide | Polls Platform
Installation
The first step is to install the Polls Platform Android SDK.
We recommend using Android Studio as an IDE and Gradle to manage dependencies.
In your build.gradle
file, add the following dependencies with the latest version of the SDK.
dependencies {
implementation 'com.polls_platform:android:1.0+'
}
Then sync the project with Gradle files.
Create a Poll
Once you have installed the SDK, you're ready to create your first poll.
- Kotlin
// configure Polls Platform SDK val config = Config( apiKey = "YOUR_API_KEY", domainConfig = DomainConfig.Subdomain(subdomain = "YOUR_SUBDOMAIN"), environment = Environment.production ) PollsPlatform.setConfig(config = config) // create a poll val poll = Poll( ownerId = ownerId, settings = settings, title = title, options = options, ) val res = PollsPlatform.createPoll(poll = poll) if (res != null) { // poll can be opened immediately in the user's browser val browserIntent = Intent(Intent.ACTION_VIEW, res.url) startActivity(browserIntent) }
Setting up Poll Data
The following is a more complete example of setting up fields for a poll.
- Kotlin
// Poll Title val title = "Which one should we book?" // Poll Settings val settings = PollSettings( multipleVotes = true, postVoteAction = PostVoteAction.shareVote ) // Poll Options val options = arrayListOf<PollOption>( PollOption.default( title = "This is the first option", subtitle = "Subtitles are displayed below the title", details = "Details are on the third line", imageUrl = Uri.parse("https://example.com/1"), url = Uri.parse("https://example.com/images/1.png"), resourceId = "1" ), PollOption.default( title = "This is the second option", subtitle = "Subtitles are displayed below the title", details = "Details are on the third line", imageUrl = Uri.parse("https://example.com/2"), url = Uri.parse("https://example.com/images/2.png"), resourceId = "2" ) ) // all together val poll = Poll( ownerId = User.current.id, settings = settings, title = title, options = options, )
Opening the Poll
Continue to the next section to learn about the various options for opening the Poll.