Guest User

Untitled

a guest
Oct 21st, 2019
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class AppActionsApplication : Application() {
  2.  
  3. override fun onCreate() {
  4. super.onCreate()
  5. grantSlicePermissions()
  6. }
  7.  
  8. private fun grantSlicePermissions() {
  9. val sliceProviderUri = Uri.Builder().apply {
  10. scheme(ContentResolver.SCHEME_CONTENT)
  11. authority(applicationContext.packageName)
  12. }.build()
  13.  
  14. val assistantPackage = applicationContext.packageManager.queryIntentServices(
  15. Intent(VoiceInteractionService.SERVICE_INTERFACE), 0
  16. )?.let { it[0].serviceInfo.packageName } ?: return
  17.  
  18. SliceManager.getInstance(applicationContext).grantSlicePermission(assistantPackage, sliceProviderUri)
  19. }
  20. }
RAW Paste Data