car/app/app-samples/navigation/common/src/main/java/androidx/car/app/sample/navigation/common/car/MicrophoneRecorder.java
/**
     * Starts recording the car microphone, then plays it back.
     */
Starts recording the car microphone, then plays it back.
Starts recording the car microphone then plays it back .
public void record() {
        if (mCarContext.checkSelfPermission(RECORD_AUDIO)
                != PackageManager.PERMISSION_GRANTED || mCarContext.checkSelfPermission(
                WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            CarToast.makeText(mCarContext, "Grant mic permission on phone",
                    CarToast.LENGTH_LONG).show();
            List<String> permissions = Arrays.asList(RECORD_AUDIO, WRITE_EXTERNAL_STORAGE);
            mCarContext.requestPermissions(permissions, (grantedPermissions,
                    rejectedPermissions) -> {
                if (grantedPermissions.contains(RECORD_AUDIO)) {
                    record();
                }
            });
            return;
        }
        CarAudioRecord record = CarAudioRecord.create(mCarContext);
        Thread recordingThread =
                new Thread(
                        () -> doRecord(record),
                        "AudioRecorder Thread");
        recordingThread.start();
    }
public void record ( ) { if ( mCarContext . checkSelfPermission ( RECORD_AUDIO ) != PackageManager . PERMISSION_GRANTED || mCarContext . checkSelfPermission ( WRITE_EXTERNAL_STORAGE ) != PackageManager . PERMISSION_GRANTED ) { CarToast . makeText ( mCarContext , "Grant mic permission on phone" , CarToast . LENGTH_LONG ) . show ( ) ; List < String > permissions = Arrays . asList ( RECORD_AUDIO , WRITE_EXTERNAL_STORAGE ) ; mCarContext . requestPermissions ( permissions , ( grantedPermissions , rejectedPermissions ) -> { if ( grantedPermissions . contains ( RECORD_AUDIO ) ) { record ( ) ; } } ) ; return ; } CarAudioRecord record = CarAudioRecord . create ( mCarContext ) ; Thread recordingThread = new Thread ( ( ) -> doRecord ( record ) , "AudioRecorder Thread" ) ; recordingThread . start ( ) ; }
Starts recording the car microphone, then plays it back.
Starts recording the car microphone then plays it back .