Commented's Mobile SDK for Android allows you to integrate Commented's commenting and collaboration features seamlessly into your Android application. With this SDK, you can provide a collaborative environment for your app users to leave comments and feedback right within your mobile app.
Mobile SDK Installation for Android: A Step-by-Step Guide
Follow these steps to install Commented's Mobile SDK on your Android application:
Step 1: Add the SDK to Your Project
In your project-level build.gradle file, add the mavenCentral repository if it's not already added. If you are using Groovy, modify the build.gradle file; otherwise, if you are using Kotlin DSL, update the settings.gradle.kts file.
buildscript { repositories { mavenCentral() // Add this line if not already present // ... } // ... }
In your app-level build.gradle file, add the SDK dependency:
For Kotlin.dsl
dependencies { // ... implementation("io.commented.android:commented:commented-sdk-version") // Replace 'commented-sdk-version' with the latest. // ... }
For Groovy
dependencies { // ... implementation 'io.commented.android:commented:commented-sdk-version' // Replace 'commented-sdk-version' with the latest. // ... }
Step 2: Sync Gradle
After adding the dependency, sync your project and download the SDK.
You may need to clean and rebuild your project.
Step 3: Initialize the SDK
Here's how you initialize the Commented SDK in the activity you want to use:
For Kotlin
import android.app.Application
import com.commented.sdk.CommentedActivity
// If you are using multiple activities, apply this either in a BaseActivity or
// in the onCreate method of the specific activity where you want it to take effect.
class MainActivity : ComponentActivity() {
override fun onCreate() {
super.onCreate()
// Initialize the SDK here
CommentedActivity(this@YourActivity).setupCommented("projectId")
}
}
// You can get your projectId from the Commented Dashboard.
// Open your project and copy the ID from the URL.
// Example: https://app.commented.io/projects/1ebce021-1243-28b7-a16d-1efc6c712358
// projectId = "1ebce021-1243-28b7-a16d-1efc6c712358"
For Java
import android.app.Application;
import com.commented.sdk.CommentedActivity;
// If you are using multiple activities, apply this either in a BaseActivity or
// in the onCreate method of the specific activity where you want it to take effect.
public class MainActivity extends ComponentActivity {
@Override
public void onCreate() {
super.onCreate();
// Initialize the SDK here
new CommentedActivity(this@YourActivity).setupCommented("projectId");
}
}
// You can get your projectId from the Commented Dashboard.
// Open your project and copy the ID from the URL.
// Example: https://app.commented.io/projects/1ebce021-1243-28b7-a16d-1efc6c712358
// projectId = "1ebce021-1243-28b7-a16d-1efc6c712358"
Step 4: Build and Run Your App
Build and run your Android application to test the integration of the com.commented.sdk.