.getExtras()' on a null object reference

后端 未结 2 1872
没有蜡笔的小新
没有蜡笔的小新 2021-01-26 07:36

I am trying to pass a few values between my activities to make a game work. However, the new activity after passing the information always returns null when I try to .getExtras(

2条回答
  •  时光取名叫无心
    2021-01-26 07:54

    Wait until onCreate to get the intent. Your trying to getIntent() when the class is instantiated instead of when the Activity is active.

    Then just assign the values found to a field and other methods inside that class can access the field.

提交回复
热议问题