.getextras()' On A Null Object Reference
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().
Solution 1:
Move
Bundleextras= getIntent().getExtras();
ArrayList<Integer> players = extras.getIntegerArrayList("players");
intcurrentPlayer= extras.getInt("newPlayerNum");
into onCreate()
. getIntent()
needs a Context
which isn't available before onCreate()
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_three_sign_game);
// hereBundleextras= getIntent().getExtras();
ArrayList<Integer> players = extras.getIntegerArrayList("players");
intcurrentPlayer= extras.getInt("newPlayerNum");
}
Post a Comment for ".getextras()' On A Null Object Reference"