Created
June 5, 2021 08:55
-
-
Save Oleur/8e40ae62e8a29fbdb227f1399cfa3f8f 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
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