Code example for Activity

Methods: startActivityForResult

0
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel);
        intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
        intent.putExtra(RecognizerIntent.EXTRA_PROMPT, ContextManager.getContext().getString(prompt));
        String detailMessage = "Error! No Fragment or Activity was registered to handle this voiceinput-request!";
        if (activity != null)
            activity.startActivityForResult(intent, requestCode);
        else if (fragment != null)
            fragment.startActivityForResult(intent, requestCode);
        else 
            Log.e("Astrid VoiceInputAssistant", detailMessage, new IllegalStateException(detailMessage));
    } 
 
    /** 
     * This callback-method has to be called from Fragment.onActivityResult within your fragment 
     * with parameters directly on passthru.<br> 
     * You can check in your fragment if it was really a RecognizerIntent that was handled here, 
     * if so, this method returns true. In this case, you should call super.onActivityResult in your 
     * fragment.onActivityResult. 
     * <p> 
     * If this method returns false, then it wasnt a request with a RecognizerIntent, so you can handle 
     * these other requests as you need.