我尝试直接访问此活动但强制关闭:
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.log);
historyView = (TextView) findViewById (R.id.historyView);
String data = (String) getIntent().getExtras().get("data");
try { FileInputStream fin = openFileInput("data.txt"); InputStreamReader isr = new InputStreamReader(fin);
char[] inputBuffer = new char[data.length()];
isr.read(inputBuffer);
String readString = new String(inputBuffer);
boolean isTheSame = data.equals(readString);
historyView.setText(readString);
}
catch (FileNotFoundExceptione) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
然而,当我从另一个写入并传递data
的活动访问它时,它正在工作。为什么?究竟是什么问题?