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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:49:25+00:00 2026-06-17T21:49:25+00:00

im trying to start the calendar sync programatically using this code Bundle bundle =

  • 0

im trying to start the calendar sync programatically using this code

Bundle bundle = new Bundle();
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_FORCE, true);
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_SETTINGS, true);

ContentResolver.requestSync(accounts[0], "com.android.calendar", bundle);

i want a way so i can know when sync complete so i can read data from the calendar
i tried doing this

while (ContentResolver.isSyncActive(accounts[0], "com.android.calendar")) {
System.out.println("looping: " + i);
}

readLocalCalendar();
readLocalEvents();

but the system exit the loop before the sync ends and i can still see the sync sign at the status bar, so any help so i can read calendar events after sync completle done ??

thanks

  • 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-17T21:49:26+00:00Added an answer on June 17, 2026 at 9:49 pm

    Another option would be to register a broadcast receiver to tell you when the sync is finished like this:

    public class UpdateableActivity extends Activity {
        public static final String ACTION_FINISHED_SYNC = "your.package.ACTION_FINISHED_SYNC";
    
        private static IntentFilter syncIntentFilter = new IntentFilter(ACTION_FINISHED_SYNC);
    
        private BroadcastReceiver syncBroadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                // update your views
            }
        };
    
        @Override
        protected void onResume() {
            super.onResume();
            // register for sync
            registerReceiver(syncBroadcastReceiver, syncIntentFilter);
            // do your resuming magic
        }
    
        @Override
        protected void onPause() {
            unregisterReceiver(syncBroadcastReceiver);
            super.onPause();
        }
    }
    

    Inside your SyncAdapter use this when done:

    getContext().sendBroadcast(new Intent(UpdateableActivity.ACTION_FINISHED_SYNC));  
    

    You can also use this for when starting or updating the status of the sync 😉

    Update: Updated the code to avoid leaks and making sure the activity is still active (onResume/onPause)

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

Sidebar

Related Questions

i'm trying to fetch event from a calendar, and i'm doing it using this
I am trying to create a google calendar event using curl this is my
I am trying to add calendar event using the below code in my android
I'm trying to start an Intent for a navigation: startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(google.navigation:q= + item.getPoint().getLatitudeE6()/1E6
I am trying to start a new Rails project but I am getting a
I am trying to send a calendar request mail through my php code. I
I am trying to get a date range using Guava's new Range functionality, via
I'm trying to insert into jQuery full calendar event data, which in this case
I am trying to start a new activity when you click on a date
I am trying to build a calendar view using django and trying to avoid

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.