0

我不断收到一个错误,显示:

(04-04 23:26:29.557:E/dalvikvm(716):无法打开堆栈跟踪文件'/data/anr/traces.txt':权限被拒绝)。

请帮忙。我正在尝试为 android 应用程序传递数据。

public class Data extends Activity implements OnClickListener{
Button start, startFor;
EditText sendET;
TextView gotAnswer;
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.get);
    initialize();

}
private void initialize(){
    start = (Button) findViewById(R.id.bSA);
    startFor = (Button) findViewById(R.id.bSAFR);
    sendET = (EditText) findViewById(R.id.etSend);
    gotAnswer = (TextView) findViewById(R.id.tvGot); 
    start.setOnClickListener(this);
    startFor.setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
    // TODO Auto-generated method stub
    switch(arg0.getId()){
    case R.id.bSA:
        String bread = sendET.getText().toString();
        Bundle basket = new Bundle();
        basket.putString("key", bread);
        Intent a = new Intent(Data.this,OpenedClass.class);
        a.putExtras(basket);
        startActivity(a);
        break;
    case R.id.bSAFR:
        Intent i = new Intent(Data.this,OpenedClass.class);
        startActivityForResult(i,0);
        break;
    }
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
}

}
package com.Christian.Amaro;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;

public class OpenedClass extends Activity implements OnClickListener,
    OnCheckedChangeListener {
TextView question, test;
Button returnData;
RadioGroup selectionList;
String gotBread,setData;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.send);
    inilialize();
    Bundle gotBasket = getIntent().getExtras();
    gotBread = gotBasket.getString("key");
    question.setText(gotBread);
}

private void inilialize() {
    // TODO Auto-generated method stub
    question = (TextView) findViewById(R.id.tvQuestion);
    test = (TextView) findViewById(R.id.tvText);
    returnData = (Button) findViewById(R.id.bReturn);
    returnData.setOnClickListener(this);
    selectionList = (RadioGroup) findViewById(R.id.rgAnswers);
    selectionList.setOnCheckedChangeListener(this);

}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub

}

@Override
public void onCheckedChanged(RadioGroup arg0, int arg1) {
    // TODO Auto-generated method stub
    switch (arg1) {
    case R.id.rCrazy:
        setData = "Probably right!";
        break;
    case R.id.rSexy:
        setData = "Definitely Probably right!";

        break;

    case R.id.rBoth:
        setData = "Spot On!";
        break;
    }
    test.setText(setData);
}

}
4

1 回答 1

1
adb shell
root@android: # cd /data/anr
root@android:/data/anr # ls -l traces.txt
-rw-rw-rw- system   system      76808 2013-04-05 13:03 traces.txt
root@android:/data/anr #

-rw-rw-rw 是你应该看到的(表示读写权限)

如果你看到不同的东西,做

root@android:/data/anr # chmod 666 traces.txt

PS你的设备必须root,否则你将无法得到这个问题:)

于 2013-04-05T04:58:03.997 回答