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

  • Home
  • SEARCH
  • 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 6242681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:59:57+00:00 2026-05-24T11:59:57+00:00

I have an application that communicates to server. I want my application to READ

  • 0

I have an application that communicates to server. I want my application to READ ONLY the socket’s inputstream when NEW DATA is available for fetching.

Currently, I create a timer that scheduled for the reading of socket’s inputstream every 20ms(polling) using SocketChannel class of java.nio.channels. This is not that good because it will end up of reading the socket even if there’s no available data. And it drains the battery fast.

Is there an API for Android that will tell or send a flag to the connected client whenever a new data is available so that it is the only time I will read the inputstream?

  • 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-24T11:59:58+00:00Added an answer on May 24, 2026 at 11:59 am

    See this, but the short answer is no, there is no API for this. BTW, SocketChannel/Selector won’t actually read the socket if not data is available, just check it’s status.

    For push notifications, you might check the Android Cloud to Device Messaging Framework.
    AFIAK, it’s implemented in a similar fashion: they keep a socket open, and send notifications
    when available. It is most probably already tuned for low battery usage, and is part of the OS, so might be worth a try (2.2 and above).

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

Sidebar

Related Questions

I have a client/server application that communicates with .Net remoting. I need my clients
I have an application that uses rest to communicate to a server, i would
I have a .NET client application that needs to communicate with a server using
I have a web application that communicates to a WCF service through a WCF
I have a console application that communicates with a web service. Both of them
I have application that brings response via Ajax and creates 5-20 new jQuery click
I have a Delphi application that communicates with web servers on the Internet using
We have a server application that has one module installed on a separate server,
I am developing an application that communicates (UDP communication) with our server remotely through
I have a Java Web Start Application which communicates against my server via a

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.