Code example for JSONArray

Methods: getString, length

0
        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 
                String temp = args.getString(0);
                reqCode = Integer.parseInt(temp);
            } 
            if (args.length() > 1) {
                // Maximum number of matches, 0 means the recognizer decides 
                String temp = args.getString(1);
                maxMatches = Integer.parseInt(temp);
            } 
            if (args.length() > 2) {
                // Optional text prompt 
                prompt = args.getString(2);
            } 
        } 
        catch (Exception e) {
            Log.e(LOG_TAG, String.format("startSpeechRecognitionActivity exception: %s", e.toString()));
        }