07.01.2013 Views

David Defour - Université de Perpignan

David Defour - Université de Perpignan

David Defour - Université de Perpignan

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Option 2: Adding One Piece of<br />

Data at a Time to Intent<br />

• I<strong>de</strong>a<br />

–Add individual pieces of data to the Intent. No need to<br />

explicitly create and attach a Bundle.<br />

• You use the overloa<strong>de</strong>d “putExtra” method. The first argument is<br />

the key (String), and the second argument is the value, which<br />

can be of any standard type. However, the co<strong>de</strong> that retrieves the<br />

value later needs to know type.<br />

• Syntax<br />

yourIntent.putExtra("key1", someDouble);<br />

yourIntent.putExtra("key2", someString);<br />

…<br />

– Unlike putBlah for Bundle, these putExtra methods return the Intent, so you<br />

can do jQuery-like chaining:<br />

380<br />

jeudi 26 janvier 12<br />

» yourIntent.putExtra(…).putExtra(…) … .putExtra(…);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!