Code example for List

Methods: isEmpty

0
     * Checks if a recognizer is present on this device 
     */ 
    private boolean IsSpeechRecognizerPresent() { 
        PackageManager pm = cordova.getActivity().getPackageManager();
        List<ResolveInfo> activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
        return !activities.isEmpty();
    } 
 
    /** 
     * Fire an intent to start the speech recognition activity. 
     * 
     * @param args Argument array with the following string args: [req code][number of matches][prompt string] 
     */ 
    private void startSpeechRecognitionActivity(JSONArray args) {
        int reqCode = 42;   //Hitchhiker?
        int maxMatches = 0;
        String prompt = "";
 
        try { 
            if (args.length() > 0) {
                // Request code - passed back to the caller on a successful operation