Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1083717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:28:17+00:00 2026-05-16T22:28:17+00:00

I have an application that uses a service to create an ArrayList of custom

  • 0

I have an application that uses a service to create an ArrayList of custom objects (MyObject) every x seconds. I then want my Activity to obtain this ArrayList.

I’m currently planning on having the Service send a message to the Activity’s handler every time it finishes the query for the data. I want the message to the Handler to contain the ArrayList of MyObjects.

When building the method in the Activity to get this ArrayList out of the message, I noticed that I couldn’t.

If I tried

msg.getData().getParcelableArrayList("myObjects")

Then the method I was passing it to that expected an ArrayList wouldn’t accept it. If I tried casting the results:

(ArrayList<MyObject>)msg.getData().getParcelableArrayList("myObjects")

I received the error: Cannot cast from ArrayList<Parcelable> to ArrayList<MyObject>

MyObject implements Parcelable and I have successfully sent an ArrayList from my service to my activity by having my activity call a method on the service to retrieve it. I’m trying to go away from having my activity poll my service for this data, though.

1) How can I send an ArrayList inside the bundle in a message to handler?

2) Is there a different model I should be using to have my service update the data in my Activity that may or may not be visible? I always want the data in my activity to be the latest from the Service.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:28:17+00:00Added an answer on May 16, 2026 at 10:28 pm

    There is another model that should be used. Another question I asked provided the answer:

    Suppress notifications from a service if activity is running

    As for #1, you could get around it by just removing the generics from the ArrayList declarations and casting as appropriate where needed. I know this works because that’s what I did before refactoring based on the other question asked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Web Service and an Android application that uses this web service.
If you have a windows service and a windows forms application that uses the
I have an application that is installed per-machine (since it uses a service). One
I have an application that is structured as an service layer wich uses a
I have a C# application that uses a Windows service that is not always
I have client application that uses WCF service to insert some data to backend
I have an ASP.NET MVC 3 application that uses a WCF service within the
I have a JSP struts application that uses Spring to integrate with the services/dao/database.
I have an application that uses a ResourceDictionary to set the styles, which it
I have an application that uses Hibernate. It generated the following SQL statement. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.