提取自环信的demo,只要给按钮加上这个监听就能方便实现监听功能,有需要的可以看下
package com.zhiye.emaster.voice;
import java.io.IOException;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.media.MediaRecorder;
import android.os.Handler;
import android.os.Message;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.zhiye.emaster.message.MyVoicelister;
import com.zhiye.emaster.ui.R;
import com.zhiye.emaster.ui.UiMessage;
import com.zhiye.emaster.util.AppUtil;
public class PressToSpeakListen implements View.OnTouchListener {
ProgressBar bar;
TextView soundtext;
RelativeLayout recording_container;
Context mContext;
String myVoicepath;
MediaRecorder mRecorder;
private boolean mRecorderisstart;
TextView recordingHint;
ImageView micImage;
private Drawable[] micImages;
doneRecordListener mListener;
public interface doneRecordListener{
public void doneRecord(String path);
}
@SuppressLint("HandlerLeak")
Handler mRecorderhandler=new Handler(){
@Override
public void handleMessage(Message msg) {