Warning: Creating default object from empty value in /home/agilemed/aendeavors.com/wp-includes/ms-load.php on line 138

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/agilemed/aendeavors.com/wp-includes/ms-load.php:138) in /home/agilemed/aendeavors.com/wp-content/plugins/amazon-product-in-a-post-plugin/amazon-product-in-a-post.php on line 102

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/agilemed/aendeavors.com/wp-includes/ms-load.php:138) in /home/agilemed/aendeavors.com/wp-content/plugins/amazon-product-in-a-post-plugin/amazon-product-in-a-post.php on line 102
Android Programming: Transferring Data Between Intents » Agile Tech

«

»

Apr
18

Android Programming: Transferring Data Between Intents

While working on the development of some new applications, I have tried transferring complex variables to new intents. For example:

Transferring a single variable, or set of single variable is easily accomplished by adding them to the intent.

   1: Intent i = new Intent();

   2: i.setClassName("packageName", "packageName.IntentClass");

   3: String term = "data to pass";

   4: i.putExtra("packageName.term", term);

   5: startActivity(i);

In the called intent, we then get this data by calling getExtras():

   1: Bundle extras = getIntent().getExtras();

   2: String term = extras.getString("packageName.term");

However, what if we want to pass more complex data? As you can see above, the data types that can be added as extras are somewhat limited. In order to pass an object, it must first implement either the Parcelable or Serializable class. Our next post will be on how to implement the Parcelable class, followed by a post on how to integrate a data service.

Leave a Reply

Your email address will not be published.


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>