Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.media.MediaRecorder;

import android.os.SystemClock;

public class Main {
    private static MediaRecorder mRecorder = null;
    private static boolean isRecording = false;
    private static long startTime = 0;

    public static long stopRecord() {
        if (isRecording) {
            try {
                mRecorder.stop();
                mRecorder.release();
            } catch (Exception e) {
            } finally {
                mRecorder = null;
                isRecording = false;
            }
            return SystemClock.elapsedRealtime() - startTime;
        } else {
            return 0;
        }
    }

    public void release() {
        mRecorder.stop();
        mRecorder.reset();
        mRecorder = null;
        isRecording = false;
    }
}