我有一个活动,它使用如下意图将数据发送到另一个活动:
public void periodDateSharedPreferences(int calculatedPeriodYear, int calculatedPeriodMonth, int calculatedPeriodDay)
{
SharedPreferences periodDatePreferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = periodDatePreferences.edit();
editor.putInt("periodChosenDay",calculatedPeriodDay);
editor.putInt("periodChosenMonth",calculatedPeriodMonth);
editor.putInt("periodChosenYear",calculatedPeriodYear);
editor.commit();
Toast.makeText(birthDate.this,"The date was saved", Toast.LENGTH_LONG).show();
Intent saved2 = new Intent(birthDate.this,MenuActivity.class);
saved2.putExtra("DueDateChanged", true);
startActivity(saved2);
finish();
}
和其他活动收到此意图如下:
static String DueDateChanged = "com.app.antiwal7amel.DueDateChanged";
Intent intent = getIntent();
String message = intent.getStringExtra(MenuActivity.DueDateChanged);
tv.setText(message);
super.onResume();
但是当我运行它时,我在意图中收到了一个空数据!哪里有问题 ?