我在我的应用程序中实现onPause()
了onResume()
如下方法:
protected void onPause() {
super.onPause();
String receiver = phoneNoField.getText().toString();
String message = messageBody.getText().toString();
getIntent().putExtra(MESSAGE_RECEIVER, receiver);
getIntent().putExtra(MESSAGE_BODY, message);
Log.d(TAG, receiver + " " + message);
}
protected void onResume() {
super.onResume();
String receiver = getIntent().getStringExtra(MESSAGE_RECEIVER);
String message = getIntent().getStringExtra(MESSAGE_BODY);
if(receiver != null)
phoneNoField.setText(receiver);
if(message != null)
messageBody.setText(message);
Log.d(TAG, receiver + " " + message);
}
调用方法时onPause()
,我看到值已设置。但在我的onResume()
方法中getStringExtra()
总是返回null
。我的方法有什么问题吗?