'Why is resolveList for VoiceInteractionService.SERVICE_INTERFACE on Android always empty

Im investigating the use of slices in my android apps shortcuts

the google docs have this snippet of code to grant permission to slices

public class MyApplication extends Application {

  private static final String SLICE_AUTHORITY = "...";

  @Override
  public void onCreate() {
    super.onCreate();
    grantSlicePermissions();
  }

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

    String assistantPackage = getAssistantPackage(context);
    if (assistantPackage == null) {
      return;
    }
    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;
  }
}

when i execute the above code within my application the following line always returns an empty list

List<ResolveInfo> resolveInfoList = packageManager.queryIntentServices(
            new Intent(VoiceInteractionService.SERVICE_INTERFACE), 0);

what is my mistake?

if this list is empty no permissions are granted



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source