Hi
You can pass the data between Activity using Bundle in Android.
To launch an activity we use to create an intent. using the intent object we can pass the data
For Example
Intent i = new Intent(this, InvokedIntent.class);
i.putExtra("floatValue", 5.0f);
i.putExtra("StringValue", "baz");
startActivity(i);
floatvalues and stringvalues are user defined keyword, In the InvokedIntent class we use this keyword to retrieve the value. Similarly we can add multiple entries here.
To read the passed value, Inside the InvokedActivity Class
Bundle extras = getIntent().getExtras();
if(extras !=null)
{
float foo = extras.getFloat("floatValue");
String bar = extras.getString("StringValue");
}
That's it.
Check: http://developer.android.com/reference/android/os/Bundle.html
Thanks.
No comments:
Post a Comment