这是我的onresume代码
@Override
public void onResume() {
super.onResume();
if (mMediationAgent != null) {
mMediationAgent.onResume(getActivity());
} else {
mMediationAgent = SupersonicFactory.getInstance();
mMediationAgent.setRewardedVideoListener(this);
mMediationAgent.initRewardedVideo(getActivity(), mAppKey, mUserId);
}
setupAd();
SharedPreferences sharedPref = getActivity().getSharedPreferences("myPref", 0);
int x = sharedPref.getInt("count", 0);
Log.e("tree", "whats x" + Long.toString(x));
if (count != 0) {
ct.start();
updateText(false);
}
}
答案 0 :(得分:1)
请在onCreateView
中添加此内容以进行首次初始化。
SharedPreferences sharedPref ;
sharedPref = getActivity().getSharedPreferences("myPref", 0);