Android using Bundle for sharing variables
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 :
We gonna share variable myValue.
In Activity1 :
myValue="string values";or
Intent intent = new Intent(MainActivity.this,NewClass.class);
Bundle bundle = new Bundle();
bundle.putString("myValue", myValue);
intent.putExtras(bundle);
startActivity(intent);
Intent intent = new Intent(MainActivity.this,NewClass.class);
intent.putExtra("myValue",AnyValue);
startActivity(intent);
In Activity2 :
Bundle bundle = getIntent().getExtras();or
String value= bundle.getString(“myValue“);
Intent intent=getIntent();
Bundle bundle=intent.getExtras();
String value= bundle.getString(“myValue“);
Baca Selengkapnya ....