6
我想從一個活動傳遞到另一個字符串,在其中我寫獲取字符串空
公共無效pdfView(文件f){
// f is: /data/data/com.example.iktabClasses/files/fileName.pdf
Intent intent = new Intent(getApplicationContext(),NewPdfActivity.class);
intent.putExtra("filename", f);
startActivity(intent);
}
,並在一個其他活動我寫道:
Bundle b=getIntent().getExtras();
if (b != null) {
filename = getIntent().getStringExtra("filename");
System.out.println("filename: "+filename);
}
但文件名總是返回爲'null'。 如何解決這個問題? 在此先感謝。 //////////////////
我把它作爲
Intent intent;
Bundle b = new Bundle();
b.putString("filename", f.toString());
intent = new Intent(getApplicationContext(),NewPdfActivity.class);
intent.putExtras(b);
startActivity(intent);
和現在工作
謝謝你,你的代碼引導我。 – 2013-04-08 14:20:46
謝謝,你的代碼也引導了我。 – teardrop 2017-01-24 14:19:07