【发布时间】:2015-11-22 20:13:16
【问题描述】:
我有三个 Android activity A、B、C。
我正在从A 活动中调用B 活动:
public void onCreate(){
Intent intent = new Intent(A.this, B.class);
startActivity(intent);
finish();
}
在B 活动的onSuccess 中我正在使用Sharedpreference:
protected void onSuccess(Bundle savedInstanceState) {
sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
/...../
editor.apply()
}
现在我想在A活动类中访问sharedPreferences的参数。在ActivityA的哪个方法中我会得到这些参数? onSuccess?。在访问这些参数之前,活动B 也将返回到活动A。我怎样才能做到这一点?我是Android 开发的新手。
#Edit
public void onCreate(){
Intent intent = new Intent(A.this, B.class);
startActivity(intent);
finish();
sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
String name = sharedpreferences.getString(Name, "");
}
【问题讨论】:
-
你的 C 活动巨魔在哪里?
标签: android android-intent android-activity sharedpreferences