Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to transfer boolean value between activities in android?

This is how I am currently doing it but, it just force closes app.

In the first activity

Intent myIntent = new Intent(Input.this, results.class);
    myIntent.putExtra("perfect", rig);
    startActivity(myIntent);`

Activity I want to transfer to

    Boolean lovers = getIntent().getExtras().getBoolean("perfect");
like image 940
DocDevelopers Avatar asked Jan 21 '26 11:01

DocDevelopers


2 Answers

As the docs say, the function is getBooleanExtra

Boolean lovers = getIntent().getExtras().getBooleanExtra("perfect");
like image 155
PearsonArtPhoto Avatar answered Jan 23 '26 00:01

PearsonArtPhoto


I am not sure about the accepted answer:: But i think it should be

Boolean lovers = getIntent().getExtras().getBoolean("perfect");
like image 44
Devrath Avatar answered Jan 23 '26 01:01

Devrath