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 1013341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:05:09+00:00 2026-05-16T10:05:09+00:00

I am a bit new to Android. What I need to do is send

  • 0

I am a bit new to Android. What I need to do is send data back and forth between an activity and a service locally. The information sent is sensitive and must not be able to be picked up by other apps. This excludes using broadcast and the onBind() function if I understand things correctly?

So the activity needs to send some string parameters to the service. Also it somehow needs to tell the service which activity started it so the service can reply to the correct class since many different activities will use this service. Once the service has fetched the information via a http request it is suppose to send that data (just a long string which will later be parsed) back to the activity that started it. How do I go about doing this? Using static variables/functions is not an option since again many actives will be using this service. Sure it would be possible to use a static array to hold the classes but that just seems ugly… It’s only possible to send simple variables (not objects) via the intent? There must be a better way to do this. I have been surfing the web for hours. Any help would be greatly appreciated.

EDIT

The example found on Android Developers [http://developer.android.com/reference/android/app/Service.html#stopSelf(int)%5D was a great help to implement a local binder.

For those of you out there interested here is some more information on my implementation so far.

  1. Once the onServiceConnected function is called a function in the service is called to set which activity it is bound to. After that both service and activity can interact with each other back and forth.
  2. Make sure that the thread in the service class has a handler. This enables the thread to send a message to its handler once it has completed its task. The handler then sends the result from the service back to its bound activity. Doing this through a handler makes sure the application is back on the main thread when this is done.
  • 1 1 Answer
  • 0 Views
  • 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-16T10:05:09+00:00Added an answer on May 16, 2026 at 10:05 am

    This excludes using broadcast and the onBind() function if I understand things correctly?

    Data exchanged between client and service via a local Binder are local method calls within a JVM.

    If you are supporting API Level 4 and higher, you can also use setPackage() on an Intent to securely send a broadcast to a particular package.

    How do I go about doing this?

    Put extras on the Intent you use with startService() or bindService(). Or call a method on the local Binder.

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

Sidebar

Related Questions

I'm new to Android development, and I've been playing around with it a bit.
I m new to android application development. I made a project on getting feeds
So I have a very simple android activity that starts a timer when you
I'm trying to create a scrollable layout in Android. Even using developers.android.com, though, I
I need to get the mjpeg stream from an IP camera, anyone know the
I have an android.net.URI object (of the kind returned by onActivityResult after MediaStore.ACTION_VIDEO_CAPTURE): it
In Android, I have some code to check whether the user has GPS switched
This is a bit unorthodox but I'm trying to figure out if there's a
Just for the disclaimer, I'm not trying to win the prize in Android Developer
I've got an app that is heavily based on remote images. They are usually

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.