我有一个从一个活动到另一个活动的常用Intent,并为第二个活动提供所需文件的路径。
Activity one:
private void onFileClick(int position)
{
File file =new File(folder+ "/"+ getListAdapter().getItem(position).toString());
Intent i = new Intent(this, (Activity two).class);
Log.e("Given File",file.toString());
i.putExtra(file.toString(), key);
startActivity(i);
}
Activity two:
@Override
protected void onCreate(Bundle savedInstanceState)
{
Intent i = getIntent();
String filepath = i.getStringExtra((Activity One).key); //Returns null
File parseFile = new File(filepath); //NullpointerExeption
}
我是否错误地初始化了意图?