2

I am trying to implement google assistant into my own android app, I have been following actions on google example: https://github.com/actions-on-google/appactions-fitness-kotlin/issues/9.

I am getting

java.lang.SecurityException: Caller must own content://at.oeamtc.android.oeamtclib.MySliceProvider

This is the part where it is crashing, on

SliceManager.getInstance(context) .grantSlicePermission(assistantPackage, sliceProviderUri);

private void grantAssistantPermissions() {
Context context = getApplicationContext();
Uri sliceProviderUri =
new Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority(OeamtcSliceProvider.SLICE_AUTHORITY)
.build();

String assistantPackage = getAssistantPackage(context);
if (assistantPackage == null) {
    return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    SliceManager.getInstance(context)
            .grantSlicePermission(assistantPackage, sliceProviderUri);
    }
}

private String getAssistantPackage(Context context) {
    PackageManager packageManager = context.getPackageManager();
    List<ResolveInfo> resolveInfoList = packageManager.queryIntentServices(
            new Intent(VoiceInteractionService.SERVICE_INTERFACE), 0);
    if (resolveInfoList.isEmpty()) {
        return null;
    }
    return resolveInfoList.get(0).serviceInfo.packageName;
}
Donki
  • 660
  • 6
  • 21
  • Please try first Fitness App and make sure you're able to run display the Slice successfully. This exercise will help you isolate what step might be missing in your app. My hunch is that one of the steps in the requirements is missing. https://github.com/actions-on-google/appactions-fitness-kotlin#requirements If after running these steps you're still facing issues, we would have established a baseline to troubleshoot. Thanks! – Diego Jul 02 '19 at 21:36
  • With both Fitness App and my own app, when i try to run slices, google assistant is stuck loading: https://imgur.com/oFEgYZ3 . Opening deeplinks is working fine on both. – Donki Jul 03 '19 at 07:24
  • Got it. Thanks for replicating the issue with the fitness app. Do you mind going ahead and opening a ticket directly in the issue tracker? https://issuetracker.google.com/issues/new?component=617864&template=1257475 I'll add more comments and follow up with the teams. Thanks again! – Diego Jul 03 '19 at 15:47
  • Couple of things. Are you using the androidX version? Where are you calling this method? Are you sure that the SliceProvider declared in AndroidManifest has the authority as "at.oeamtc.android.oeamtclib.MySliceProvider"? – Marcel Jul 04 '19 at 03:42
  • I don't have androidX integrated on my project and we are not planning to do so anytime soon. Google guidelines says that we can work with slices without androidX. The method is being called on the Application class, and the manifest looks fine, same as the fitness app. – Donki Jul 11 '19 at 08:28

0 Answers0