Skip to content

Instantly share code, notes, and snippets.

@Oleur
Created June 5, 2021 08:55
Show Gist options
  • Save Oleur/8e40ae62e8a29fbdb227f1399cfa3f8f to your computer and use it in GitHub Desktop.
Save Oleur/8e40ae62e8a29fbdb227f1399cfa3f8f to your computer and use it in GitHub Desktop.
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
grantAssistantPermissions()
}
private fun grantAssistantPermissions() {
getAssistantPackage()?.let { assistantPackage ->
val sliceProviderUri = Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority("test.aircall.todo.slices")
.build()
SliceManager.getInstance(this).grantSlicePermission(assistantPackage, sliceProviderUri)
}
}
private fun getAssistantPackage(): String? {
val resolveInfoList = packageManager?.queryIntentServices(
Intent(VoiceInteractionService.SERVICE_INTERFACE), 0
)
return resolveInfoList?.firstOrNull()?.serviceInfo?.packageName
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment