Skip to content

Instantly share code, notes, and snippets.

@maxirosson
Last active June 25, 2021 10:55
Show Gist options
  • Save maxirosson/ee6ec35a5ea77b01afb137028a216b5c to your computer and use it in GitHub Desktop.
Save maxirosson/ee6ec35a5ea77b01afb137028a216b5c to your computer and use it in GitHub Desktop.
object AppUtils {
// The package name of the application
const val manifestPackageName = "com.example.myapp"
// The application id of the application
val applicationId: String
get() {
val context = ...
// You could receive the context as parameter here
// or obtain from a any context container of your app
return context.applicationContext.packageName
}
// The application id of the application on release mode.
// This method removes the .debug suffix
val releaseApplicationId: String by lazy {
val buildType = BuildConfig.BUILD_TYPE
return@lazy if (buildType == "release") {
applicationId
} else {
applicationId.replace(".${buildType}", "")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment