Android using Bundle for sharing variables

Posted by Unknown Jumat, 20 September 2013 0 komentar
Sharing variables between Activities is quite important point during development time of your Application. This  Example suppose Activity1 from where you run up other Activity2 .  
We gonna share variable myValue.

In Activity1 :
myValue="string values";
Intent intent = new Intent(MainActivity.this,NewClass.class);
Bundle bundle = new Bundle();
bundle.putString("myValue", myValue);
intent.putExtras(bundle);
startActivity(intent);
or

Intent intent = new Intent(MainActivity.this,NewClass.class);
intent.putExtra("myValue",AnyValue);
startActivity(intent);

In Activity2 :
Bundle bundle = getIntent().getExtras();
String value= bundle.getString(“myValue“);
or

Intent intent=getIntent();
Bundle bundle=intent.getExtras();
String value= bundle.getString(“myValue“);
TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: Android using Bundle for sharing variables
Ditulis oleh Unknown
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke https://androidpopuler.blogspot.com/2013/09/android-using-bundle-for-sharing.html. Terima kasih sudah singgah membaca artikel ini.

0 komentar:

Posting Komentar

Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android populer.