Using Integer From One Class In Another Android
I need some help with using integer from one activity to another. I am making some basic math program(game). It gets two random numbers, random operator, and 30 secs to solve math
Solution 1:
Try this:
Intent intent = newIntent(this, RankActivity.class);
intent.putExtra("points", pointsVar);
startActivity(intent);
In onCreate
of RankActivity
:
getIntent().getIntExtra("points", 0);
Solution 2:
so you want to pass integer value from one activity to another activity? right...
try:
Intent intent = newIntent(currentclass.this, destination.class);
intent.putExtra("point", pointvalue);
startActivity(intent);
at destination activity:
finalint getpoint = getIntent().getExtras().getInt("point");
This will solve your problem.
Solution 3:
first of all make
static variable like as public static int poenibrojanje;
in your BrzoRacunanjeActivity.class
file now you can use this variable in any other class like as
BrzoRacunanjeActivity.poenibrojanje
or you can use putExtras();
method.
in you main activity.
Intent i = newIntent(this, RankActivity.class);
i.putExtra("Value",poenibrojanje);
in your next activity
int v = (getIntent().getExtras().getInt("Value")) ;
Post a Comment for "Using Integer From One Class In Another Android"