Android onResume()未从onPause()提取信息

Android onResume()未从onPause()提取信息,android,android-intent,Android,Android Intent,我正在制作这个基于文本的小型rpg游戏,用户可以选择自己的名字、种族、职业等等 我有一个活动,用户键入他们想要使用的名称,然后从微调器中选择race类 然后,当他们点击“创建角色”按钮时,所有内容都转移到下一个活动。那很好用 问题出在onPause事件保存数据时。onResume()方法就是不起作用?视图显示为空白 以下是所选代码: (这是从其他活动中提取数据的地方) (这是onPause()方法) (这是onResume()方法) 运行应用程序时,我没有收到任何错误。如果要在活动之间使用Sha

我正在制作这个基于文本的小型rpg游戏,用户可以选择自己的名字、种族、职业等等

我有一个活动,用户键入他们想要使用的名称,然后从微调器中选择race类

然后,当他们点击“创建角色”按钮时,所有内容都转移到下一个活动。那很好用

问题出在onPause事件保存数据时。onResume()方法就是不起作用?视图显示为空白

以下是所选代码:

(这是从其他活动中提取数据的地方)

(这是onPause()方法)

(这是onResume()方法)


运行应用程序时,我没有收到任何错误。

如果要在活动之间使用SharedReferences存储,请使用GetSharedReferences()而不是getPreferences。见详情


另外,在进行更改后,不要忘记调用
editor.commit()

尝试调用
super.onResume()在结尾。这就像它甚至没有调用方法一样。你能把完整的代码放到活动中吗?最好的实现应该在活动A中的startActivityForResult()上工作。请检查
null
,因为一些字符串内容在遇到null时不会抛出NPE,它只会显示什么。是的,我这样做了。只是没有把它写在描述里。编辑
String Name = getIntent().getStringExtra("strName");
    textViewStrName.setText(Name);

    String Race = getIntent().getStringExtra("strRace");
    textViewStrRace.setText(Race);

    String Class = getIntent().getStringExtra("strClass");
    textViewStrClass.setText(Class);
SharedPreferences preferences = getPreferences(MODE_PRIVATE);
    SharedPreferences.Editor editor = preferences.edit();
    editor.clear();
    String strName = textViewStrName.getText().toString();
    String strRace = textViewStrRace.getText().toString();
    String strClass = textViewStrClass.getText().toString();
    editor.putString("strName", strName);
    editor.putString("strRace", strRace);
    editor.putString("strClass", strClass);
editor.commit();
SharedPreferences preferences = getPreferences(MODE_PRIVATE);
    TextView textViewStrName = (TextView) findViewById(R.id.textViewStrName);
    TextView textViewStrRace = (TextView) findViewById(R.id.textViewStrRace);
    TextView textViewStrClass = (TextView) findViewById(R.id.TextViewStrClass);
    TextView textViewStrAlliance = (TextView) findViewById(R.id.textViewStrAlliance);


        textViewStrName.setText(preferences.getString("strName", null));
        textViewStrRace.setText(preferences.getString("strRace", null));
        textViewStrClass.setText(preferences.getString("strClass", null));
        textViewStrAlliance.setText(preferences.getString("strAlliance",
                null));