Code example for Context

Methods: getPackageManager

0
     * If this method returns true, internal use of it enables the registered microphone-button. 
     * 
     * @return whether this phone supports voiceinput 
     */ 
    public static boolean voiceInputAvailable(Context context) {
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> activities = pm.queryIntentActivities(
                new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
        return (activities.size() != 0);
    } 
 
    private VoiceRecognizer() { 
        // 
    } 
 
    private static VoiceRecognizer instance = null;
 
    public static VoiceRecognizer instantiateVoiceRecognizer(Context context, RecognizerApiListener listener, ImageButton voiceAddButton) {
        synchronized(VoiceRecognizer.class) { 
            if (instance == null)
                instance = new VoiceRecognizer();