05-29 14:12:21.470: E/Trace(7584): error opening trace file: No such file or directory (2)
05-29 14:12:21.520: W/dalvikvm(7584): Refusing to reopen boot DEX '/system/framework/hwframework.jar'
05-29 14:12:22.390: I/Adreno200-EGL(7584): <qeglDrvAPI_eglInitialize:299>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_JB_REL_2.0.3.04.01.01.21.010_msm8625_JB_REL_2.0.3_Merge_release_AU (Merge)
05-29 14:12:22.390: I/Adreno200-EGL(7584): Build Date: 10/26/12 Fri
05-29 14:12:22.390: I/Adreno200-EGL(7584): Local Branch: 
05-29 14:12:22.390: I/Adreno200-EGL(7584): Remote Branch: quic/jb_rel_2.0.3
05-29 14:12:22.390: I/Adreno200-EGL(7584): Local Patches: NONE
05-29 14:12:22.390: I/Adreno200-EGL(7584): Reconstruct Branch: AU_LINUX_ANDROID_JB_REL_2.0.3.04.01.01.21.010 +  NOTHING
05-29 14:12:22.700: I/Choreographer(7584): Skipped 43 frames!  The application may be doing too much work on its main thread.
05-29 14:12:23.590: E/dalvikvm(7584): GC_CONCURRENT freed 148K, 42% free 8210K/13955K, paused 17ms+2ms, total 43ms
05-29 14:12:26.590: W/System.err(7584): java.io.IOException: open failed: EROFS (Read-only file system)
05-29 14:12:26.610: W/System.err(7584):  at java.io.File.createNewFile(File.java:940)
05-29 14:12:26.610: W/System.err(7584):  at com.example.test2.MainActivity.collect(MainActivity.java:217)
05-29 14:12:26.610: W/System.err(7584):  at com.example.test2.MainActivity$3.onClick(MainActivity.java:100)
05-29 14:12:26.610: W/System.err(7584):  at android.view.View.performClick(View.java:4100)
05-29 14:12:26.610: W/System.err(7584):  at android.view.View$PerformClick.run(View.java:17016)
05-29 14:12:26.610: W/System.err(7584):  at android.os.Handler.handleCallback(Handler.java:615)
05-29 14:12:26.610: W/System.err(7584):  at android.os.Handler.dispatchMessage(Handler.java:92)
05-29 14:12:26.610: W/System.err(7584):  at android.os.Looper.loop(Looper.java:137)
05-29 14:12:26.620: W/System.err(7584):  at android.app.ActivityThread.main(ActivityThread.java:4813)
05-29 14:12:26.620: W/System.err(7584):  at java.lang.reflect.Method.invokeNative(Native Method)
05-29 14:12:26.620: W/System.err(7584):  at java.lang.reflect.Method.invoke(Method.java:511)
05-29 14:12:26.620: W/System.err(7584):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
05-29 14:12:26.620: W/System.err(7584):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
05-29 14:12:26.620: W/System.err(7584):  at dalvik.system.NativeStart.main(Native Method)
05-29 14:12:26.620: W/System.err(7584): Caused by: libcore.io.ErrnoException: open failed: EROFS (Read-only file system)
05-29 14:12:26.630: W/System.err(7584):  at libcore.io.Posix.open(Native Method)
05-29 14:12:26.630: W/System.err(7584):  at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
05-29 14:12:26.630: W/System.err(7584):  at java.io.File.createNewFile(File.java:933)
05-29 14:12:26.630: W/System.err(7584):  ... 13 more
05-29 14:12:27.020: E/dalvikvm(7584): GC_CONCURRENT freed 1812K, 40% free 8498K/13955K, paused 12ms+3ms, total 64ms
05-29 14:12:27.150: E/dalvikvm(7584): GC_CONCURRENT freed 1930K, 39% free 8536K/13955K, paused 2ms+6ms, total 54ms
程序如下
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;import android.app.Activity;
import android.graphics.Color;
import android.graphics.Paint;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;/*
 * 本程序为加速度传感器的应用程序,今后可根据此开发其他
 */public class MainActivity extends Activity implements SensorEventListener {
    private SensorManager mSensorManager;
private final float FILTERING_VALAUE = 0.1f;
private float lowX,lowY,lowZ,highX,highY,highZ;
double CurrTime,LastTime;
float lastVirb=0;
float AccThres=3; //加速度阈值
float AccTime=1000; //时间间隔阈值,单位毫秒
boolean switchON;
SurfaceView sfv;
Paint mPaint;
draw1 clsOscilloscope=new draw1();     public void onCreate(Bundle savedInstanceState) {    
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        switchON=false;
        
        final Button btn1=(Button)findViewById(R.id.button1);
        final Button btn2=(Button)findViewById(R.id.button2);
        final Button btn3=(Button)findViewById(R.id.button3);
        
        btn1.setText("点击开始");
        btn2.setText("清零");
        btn3.setText("画图");
        
        LastTime=System.currentTimeMillis();
        
        mSensorManager=(SensorManager)getSystemService(SENSOR_SERVICE);
        sfv = (SurfaceView) this.findViewById(R.id.surfaceview_draw); 
        mPaint = new Paint();    
        mPaint.setColor(Color.GREEN);// 画笔为绿色     
        mPaint.setStrokeWidth(1);
        btn1.setOnClickListener(new Button.OnClickListener(){ @Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (switchON==false)
{
switchON=true;
btn1.setText("点击停止");
btn2.setEnabled(false);
}
else
{
switchON=false;
btn1.setText("点击开始");
btn2.setEnabled(true);
}

}
        
        });
        btn2.setOnClickListener(new Button.OnClickListener(){ @Override
public void onClick(View v) {
// TODO Auto-generated method stub
clsOscilloscope.Stop();
}
        
        });
        btn3.setOnClickListener(new Button.OnClickListener(){ @Override
public void onClick(View v) {
// TODO Auto-generated method stub
switchON=true;
try{
collect(lastVirb);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
clsOscilloscope.baseLine=sfv.getHeight()/2;  
                clsOscilloscope.Start(sfv,mPaint);
}
        
        });
    }
    
        protected void onResume(){
     super.onResume();
        List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);        //sensor1
        for (Sensor s : sensors){
         mSensorManager.registerListener(this, s, SensorManager.SENSOR_DELAY_NORMAL);
        }
        
    }
    
   
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub

} @Override
public void onSensorChanged(SensorEvent e) {
// TODO Auto-generated method stub


if (switchON==true)
{
float x = e.values[SensorManager.DATA_X];
        float y = e.values[SensorManager.DATA_Y];
        float z = e.values[SensorManager.DATA_Z];        //Low-Pass Filter
        lowX = x * FILTERING_VALAUE + lowX * (1.0f - FILTERING_VALAUE);
        lowY = y * FILTERING_VALAUE + lowY * (1.0f - FILTERING_VALAUE);
        lowZ = z * FILTERING_VALAUE + lowZ * (1.0f - FILTERING_VALAUE);        //High-pass filter
         highX = x - lowX;
         highY = y - lowY;
         highZ = z - lowZ;
        
      //output
       
        TextView textX = (TextView)findViewById(R.id.x);
        textX.setText("x:" + String.valueOf(highX));
        TextView textY = (TextView)findViewById(R.id.y);
        textY.setText("y:" + String.valueOf(highY));
        TextView textZ = (TextView)findViewById(R.id.z);
        textZ.setText("z:" + String.valueOf(highZ));
        
        float virb=(Math.abs(highX)+Math.abs(highY)+Math.abs(highZ))/3;
     //   float virb=(Math.abs(lowX)+Math.abs(lowY)+Math.abs(lowZ))/3;
        //float virb=(Math.abs(x)+Math.abs(y)+Math.abs(z)-10)/3;
       
        if ((virb>AccThres)&(Math.abs(virb-lastVirb)>AccThres))
        {
         CurrTime=System.currentTimeMillis();
         if (Math.abs(CurrTime-LastTime)>AccTime)
         {
         LastTime=CurrTime;
         }        
        }
        lastVirb=virb;
}
//onSignal();

}
public void onSignal(){

float N= (float) (6*(Math.sqrt(Math.pow(highX, 2)+Math.pow(highY,2)+Math.pow(highZ,2))));
if (N<1) {
final TextView text2 = (TextView)findViewById(R.id.textView2);
text2.setText("最佳舒适性");
} else {if ((1<N)&(N<2)) {
final TextView text2 = (TextView)findViewById(R.id.textView2);
text2.setText("良好舒适性");

} else {if ((2<N)&(N<3)) {
final TextView text2 = (TextView)findViewById(R.id.textView2);
    text2.setText("中等舒适性");

} else {if ((3<N)&(N<4)) {
final TextView text2 = (TextView)findViewById(R.id.textView2);
    text2.setText("不好舒适性");
} else {if (N>5) {
final TextView text2 = (TextView)findViewById(R.id.textView2);
    text2.setText("极差舒适性");
} } } } }

}
public void collect(float jsd) throws IOException{
File file = new File("jiasudu.txt");
        if (!file.exists()) {
            file.createNewFile();
        }
@SuppressWarnings("deprecation")
FileOutputStream fos=super.openFileOutput("jiasudu.txt", Activity.MODE_WORLD_WRITEABLE);
BufferedOutputStream bos=new BufferedOutputStream(fos, 512);
DataOutputStream dos=new DataOutputStream(bos);
while (dos.size()<=512) {
dos.writeFloat(jsd); 
}
dos.close();
}}Android应用

解决方案 »

  1.   

    看log好像没有权限进行文件操作
      

  2.   

    什么是log?
    初步接触这些不怎么懂啊
      

  3.   

    (MainActivity.java:217)
    是哪行?这错误是不是路径错了,我一般是这么写路径
    File file = new File(Environment.getExternalStorageDirectory(),
    "a.txt");
      

  4.   


    你报错那217是哪行?
    Caused by: libcore.io.ErrnoException: open failed: EROFS (Read-only file system)查这个错误引发的原因主要