2011-06-27 25 views

回答

5

最大振幅給出了給定樣品的最大振幅,所以取樣品每250毫秒和計算最大振幅

public void run() { 
      int i = 0; 
      while(i == 0) { 
       Message msg = mHandler.obtainMessage(); 
       Bundle b = new Bundle(); 
       try { 
        sleep(250); 
       } catch (InterruptedException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } 
       if (mRecorder != null) { 
        amplitude = mRecorder.getMaxAmplitude(); 
        b.putLong("currentTime", amplitude); 
        Log.i("AMPLITUDE", new Integer(amplitude).toString()); 
       } else { 
        b.putLong("currentTime", 0); 
       } 
       msg.setData(b); 
       mHandler.sendMessage(msg); 
      } 
     } 

我使用消息處理程序來修改前端使用後臺進程線程

0

創建一個始終運行的線程。 在線程做到這一點:

int amp = mrec.getMaxAmplitude(); 
    if (amp > 0) 
     yourcode; 

你需要的線程的詳細信息?