The In-App Update Library simplifies the integration of in-app updates in Android applications. It provides a straightforward way to check for updates and prompt users to update your app using Google Play's core app update features. This library is ideal for ensuring that your users always have the latest version of your app with minimal hassle.
- Easy integration of in-app updates.
- Supports immediate update flows.
- Simplified API for checking and starting updates.
- Android Studio
- An Android project with minimum SDK version 23.
To use the In-App Update Library in your project, follow these steps:
Add JitPack to your project's build file. Open your root build.gradle
file and add the following to the repositories
section:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Next, add the dependency for the In-App Update Library in your module's build.gradle
file:
dependencies {
implementation 'com.github.saurabhthesuperhero:InAppUpdate-Kotlin-Lib:8.0.2'
}
After these steps, sync your project with the Gradle files to ensure that the library is properly imported into your project.
-
Initialization:
In your
MainActivity
or any otherActivity
from which you want to start the update process, initialize theInAppUpdateManager
:import com.simplifymindfulness.inappupdate_library.InAppUpdateManager import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import com.google.android.material.composetheme.adapter.InAppUpdateKotlinLibTheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.ui.Modifier import androidx.compose.ui.layout.fillMaxSize class MainActivity : ComponentActivity() { private lateinit var activityResultLauncher: ActivityResultLauncher<IntentSenderRequest> override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) activityResultLauncher = registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result -> // Handle the result of the update flow here } InAppUpdateManager.init(this, activityResultLauncher) setContent { InAppUpdateKotlinLibTheme { Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) { HelloOpenSource() } } } } }
-
Handling Update Results:
Implement the logic to handle the result of the update flow in the
registerForActivityResult
callback.
Contributions are welcome! If you have a bug to report or a feature to suggest, please open an issue or submit a pull request.