Implement getMaxAmplitude for audioRecord
===

I am using audioRecord instead of mediarecorder in my app it's working fine but I have a logic that depends highly on the maxamplitude which is really hard to obtain using the audiorecord here is what I am using when reading the buffer 


     private void writeAudioDataToFile(){
    		byte data[] = new byte[bufferSize];
    		
    		String filename = getTempFilename();
    		FileOutputStream os = null;
    		
    		try {
    			os = new FileOutputStream(filename);
    		} catch (FileNotFoundException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		
    		int read = 0;
    		max=0;
    		if(null != os){
    			while(isRecording){
    				read = recorder.read(buffer, 0, bufferSize);
    				int amplitude = (buffer[0] & 0xff) << 8 | buffer[1];
    				amplitude = Math.abs(ab);
    			
    			if(amplitude>0&&amplitude<25000)
    				isSilence=true;			
    			else
    				isSilence=false;
    											
    				//System.out.println(">>>>>>>>>>>"+amplitude);
    				if(AudioRecord.ERROR_INVALID_OPERATION != read){
    					try {
    						os.write(buffer);
    					} catch (IOException e) {
    						e.printStackTrace();
    					}
    				}
    			}
    			
    			try {
    				os.close();
    			} catch (IOException e) {
    				e.printStackTrace();
    			}
    		}
    	}


but this doesn't work for me as the value changes real fast I need to implement something like getMaxAmplitude() for audioRecord.