1. Download our Official Android App: Forums for Android!

Apps I need to keep in contact with my server through an Android app.

Discussion in 'Android Development' started by Qasim2143214, Jul 27, 2011.

  1. Qasim2143214

    Qasim2143214 Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    21
    Joined:
    Jul 12, 2011

    Jul 12, 2011
    21
    0
    15
    The problem is, I need to request a page to my server every 5 seconds. I am using a service that loads a httpclient every 5 seconds. I'm worried that this will take up too much battery, will it? Is there any easier way to keep communication to a server?
     

    Advertisement

  2. hooked82

    hooked82 Newbie
    Rank:
    None
    Points:
    16
    Posts:
    19
    Joined:
    Jul 23, 2011

    Is it 100% required that it hit the server every 5 seconds? I'm not sure of the needs of your app, but could you potentially due some caching, or are you looking for new data in that 5 second interval?
     
  3. Qasim2143214

    Qasim2143214 Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    21
    Joined:
    Jul 12, 2011

    Jul 12, 2011
    21
    0
    15
    Yes, the user could post a message at any time, and I need to get that message to the phone ASAP, so the service I am trying to make can be "instant"
     
  4. hooked82

    hooked82 Newbie
    Rank:
    None
    Points:
    16
    Posts:
    19
    Joined:
    Jul 23, 2011

    The only thing I can think of is to possibly use a SyncAdapter, though I've never used it and don't know it's full capabilities. It's just the only thing I can come up with at this time:
    SyncAdapter.java | Android Developers

    Would that work?
     

Share This Page

Loading...