Last active
June 25, 2021 10:55
-
-
Save maxirosson/ee6ec35a5ea77b01afb137028a216b5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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