Android Package Manage isSpeechRecognitionActivityPresented( Activity callerActivity)

Here you can find the source of isSpeechRecognitionActivityPresented( Activity callerActivity)

Description

is Speech Recognition Activity Presented

Declaration

private static boolean isSpeechRecognitionActivityPresented(
        Activity callerActivity) 

Method Source Code

//package com.java2s;

import java.util.List;
import android.app.Activity;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

import android.speech.RecognizerIntent;

public class Main {

    private static boolean isSpeechRecognitionActivityPresented(
            Activity callerActivity) {//  w ww  .j av a  2  s.co m
        try {
            // getting an instance of package manager
            PackageManager pm = callerActivity.getPackageManager();
            // a list of activities, which can process speech recognition Intent
            List<ResolveInfo> activities = pm
                    .queryIntentActivities(new Intent(
                            RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);

            if (activities.size() != 0) { // if list not empty
                return true; // then we can recognize the speech
            }
        } catch (Exception e) {

        }

        return false; // we have no activities to recognize the speech
    }
}

Related

  1. disableComponent(PackageManager pm, ComponentName component)
  2. enableComponent(PackageManager pm, ComponentName component)
  3. isPackageInstalled(String packageName, PackageManager pm)
  4. getApplicationMarketPage( @Nonnull String packageName)
  5. isPackageInstalled(final String packageName, final PackageManager pm)
  6. uninstall(Context context, String packageName)
  7. uninstallApp(Context context, String packageName)
  8. installPackage(Context context, File packageFile)