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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:37:43+00:00 2026-06-10T12:37:43+00:00

I’m building an Android client for an Internet discussion board: the app downloads the

  • 0

I’m building an Android client for an Internet discussion board: the app downloads the discussions from the server and displays them using the native Android UI. It was quite easy to build the basics such as getting and displaying the content, and posting the replies back to the server.

Now I want to bring it to the next level: the app should store all the data locally on the device and sync it with the server periodically, getting the recent changes and updating the local DB. I don’t want it to check for the changes on demand; the periodic updates are better because this allows some nice features like subscribing to the updates.

Unfortunately the server is not GCM-compliant (and it will never be), it is a good old simple web server so I have to implement the sync myself.

I’ve found a comment to another question where it’s said that a timer-based check is a bad idea because the device will have to wake up and connect to the Internet. It would be much better to catch when the device begins its own data sync, but its there a way to handle this without a perioic check?

I’ve looked over many discussions on this issue; most of them discuss the ContentProviders, protocols, services like GCM/C2DM and so on. I’ve found nothing about the power efficiency.

So how to do the sync properly so my app wouldn’t drain the battery?

  • 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-06-10T12:37:45+00:00Added an answer on June 10, 2026 at 12:37 pm

    it would be better if you use GCM as the server can push updates if available that would be power efficient than polling as network will only be used when updates are available its far better than timely polling as it will check and wake the phone just to check for updates

    Important: C2DM has been officially deprecated as of June 26, 2012. This means that C2DM has stopped accepting new users and quota requests. No new features will be added to C2DM. However, apps using C2DM will continue to work. Existing C2DM developers are encouraged to migrate to the new version of C2DM, called Google Cloud Messaging for Android (GCM). See the C2DM-to-GCM Migration document for more information. Developers must use GCM for new development.

    but as you cant get with GCM you will have to go for polling itself you can use it in a power efficiant way by using alarm manager and inexact repeating

    i think that is the best power efficient way to poll periodically

    giving a sample code

    public class MyScheduleReceiver extends BroadcastReceiver {
    
        // Restart service every 30 sec
        private static final long REPEAT_TIME = 1000 * 30 ;
    
        @Override
        public void onReceive(Context context, Intent intent) {
            AlarmManager service = (AlarmManager) context
                .getSystemService(Context.ALARM_SERVICE);
            Intent i = new Intent(context, MyStartServiceReceiver.class);
            PendingIntent pending = PendingIntent.getBroadcast(context, 0, i,
                PendingIntent.FLAG_CANCEL_CURRENT);
            Calendar cal = Calendar.getInstance();
            // Start 30 seconds after boot completed
            cal.add(Calendar.SECOND, 30);
            //
            // Fetch every 30 seconds
            // InexactRepeating allows Android to optimize the energy consumption
            service.setInexactRepeating(AlarmManager.RTC_WAKEUP,
                cal.getTimeInMillis(), REPEAT_TIME, pending);
    
            // service.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
            // REPEAT_TIME, pending);
        }
    }
    

    (There is a more detailed explanation that includes the necessary manifest items.)

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.