Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android pass Long value Intent

I know

String value= value;
Intent i = new Intent(this, NextActivity.class);
i.putExtra("value",value + "");
startActivity(i)

and in NextActivity

values = getIntent().getStringExtra("value");

is used to pass the value and get value.. can any one pleaese help me how to pass the long value...

I know we can get the long value through

getIntent().getLongExtra("");

can anyone help me how to pass the value ' putExtra ' to my knowledge is used to pass string value..

like image 816
Jocheved Avatar asked Dec 11 '22 08:12

Jocheved


2 Answers

For send data

i.putExtra("key", long value);

For get Intent value in next Activity

getIntent().getLongExtra("key", 0);

Here 0 denotes default value if you not want putExtra from first Activity then in Next Activity it will take default value as 0.

like image 126
Chirag Ghori Avatar answered Dec 28 '22 22:12

Chirag Ghori


for long values also, you can use:

i.putExtra(String name, long value);
like image 36
user543 Avatar answered Dec 29 '22 00:12

user543