在我的Andoird应用程序中,我通过以下代码将额外的内容传递给其他意图:
Intent i = new Intent(getApplicationContext(), NoteDetail.class);
i.putExtra("note_id", note_id);
startActivityForResult(i, 100);在noteDetail中,通过以下代码获取附加内容:
if (i.hasExtra(Key_NOTE_ID)) {
// Must Update the note
KEY_HAS_NOTE_ID = true;
noteId = i.getStringExtra(Key_NOTE_ID);
Log.i("Note Id is >>", noteId.toString());
ConnectionDetector cd = new ConnectionDetector(
getApplicationContext());
if (cd.isConnectedToInternet()) {
new GetNoteDetail().execute();
} else {
Toast.makeText(NoteDetail.this,
R.string.not_connected_to_internet, Toast.LENGTH_SHORT)
.show();
}
}应用程序正常工作,额外的传递和接收正确,直到按下手机上的后退按钮,并返回到之前的活动。同样,当我按下noteDetail按钮并转到noteDetail activity时,之前的note_id仍然没有清除。我想要清除多余的时候,用户按手机上的后退按钮。
发布于 2012-11-13 05:31:53
在onPause()使用中:
if (getIntent().hasExtra(Key_NOTE_ID)) getIntent().removeExtra(Key_NOTE_ID);https://stackoverflow.com/questions/13351811
复制相似问题