• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to pass POJOs / data / values between activities?

 
Ranch Hand
Posts: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 2 activities

The first one grabs contact details from the ContactsContract provider

The second one displays values on a map

In the first activity, how can I pass values to the second activity?


 
James Elsey
Ranch Hand
Posts: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've found the android.app.Application class but am having some troubles getting it to work

~I'm currently getting a classCastException and I don't understand why

My "Global State" object :




This is how I'm trying to set something :





I'm getting a classCast exception on the GlobalState gs = (GlobalState) getApplication();

Any ideas?
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post the relevant part of the AndroidManifest.xml file where you to tell Android to use the GlobalState class. Seeing the actual exception (full stack trace) would also help.
 
James Elsey
Ranch Hand
Posts: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I've been looking at some tutorials, and they mention to include the "global state" class in the manifest file

I've tried their suggestion of including this, but if I put in an application tag, the manifest file won't be valid, as I already have one application set of tags

This is my manifest


 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to the page you linked to, registering a different Application class does not involve adding another <application> tag, but adding an "android:name" attribute to the <application> tag that's already there.
 
Ranch Hand
Posts: 127
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,James

I faced same situation !
in my case i created Static List<Pojo.Class> myList in Activity #1. &added pojo to List by myList.add(pojoObj);
then retried the Pojos in Activity #2 using Activity1.myList Object ;

Done ! i don't know if this is Optimal solution to the problem !!
neways hope this will help you.

Best Regards,
piyushnp


 
James Elsey
Ranch Hand
Posts: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cheers guys, I figured it out.

Basically I needed to modify the existing application tag, and to add



I was trying is as ".GlobalState", didn't realise it needed to be the fully qualified name
 
reply
    Bookmark Topic Watch Topic
  • New Topic