here is the log accord according to Plan A and Plan B when i have
SampleSyncAdapater running on Device A-OS 2.2

01-31 21:02:06.105: VERBOSE/SyncManager(206): [SyncManager.java:
653:sendCheckAlarmsMessage()] sending MESSAGE_CHECK_ALARMS
01-31 21:02:06.145: DEBUG/SyncManager(206): [SyncManager.java:
607:scheduleSync()] scheduleSync: sync of Account {name=username,
type=com.example.android.samplesync}, com.android.contacts is not
allowed, dropping request
01-31 21:02:06.165: VERBOSE/SyncManager(206): [SyncStorageEngine.java:
374:reportChange()] reportChange 1 to: [android.content.SyncManager
$7@313452f8, android.content.ContentResolver$1@314960c8]
01-31 21:02:06.175: VERBOSE/SyncManager(206): [SyncManager.java:
653:sendCheckAlarmsMessage()] sending MESSAGE_CHECK_ALARMS
01-31 21:02:06.235: VERBOSE/SyncManager(206): [SyncManager.java:
614:scheduleSync()] scheduleSync: delay 0, source 0, account Account
{name=username, type=com.example.android.samplesync}, authority
com.android.contacts, extras Bundle[{}]
01-31 21:02:06.235: VERBOSE/SyncManager(206): [SyncManager.java:
786:scheduleSyncOperation()] scheduleSyncOperation: dropping duplicate
sync operation authority: com.android.contacts account: Account
{name=username, type=com.example.android.samplesync} extras: []
syncSource: 0 when: 319845221 expedited: false
01-31 21:02:06.235: VERBOSE/SyncManager(206): [SyncStorageEngine.java:
374:reportChange()] reportChange 1 to: [android.content.SyncManager
$7@313452f8, android.content.ContentResolver$1@314960c8]
01-31 21:02:06.255: VERBOSE/SyncManager(206): [SyncManager.java:
653:sendCheckAlarmsMessage()] sending MESSAGE_CHECK_ALARMS
01-31 21:02:06.325: VERBOSE/SyncManager(206): [SyncManager.java:
614:scheduleSync()] scheduleSync: delay 0, source 2, account Account
{name=Backup Assistant, type=com.fusionone.account}, authority
com.android.contacts, extras Bundle[{}]
01-31 21:02:06.335: VERBOSE/SyncManager(206): [SyncManager.java:
786:scheduleSyncOperation()] scheduleSyncOperation: dropping duplicate
sync operation authority: com.android.contacts account: Account
{name=Backup Assistant, type=com.fusionone.account} extras: []
syncSource: 2 when: 319845328 expedited: false
01-31 21:02:06.385: VERBOSE/SyncManager(206): [SyncManager.java:
614:scheduleSync()] scheduleSync: delay 0, source 2, account Account
{name=username, type=com.example.android.samplesync}, authority
com.android.contacts, extras Bundle[{}]
01-31 21:02:06.395: VERBOSE/SyncManager(206): [SyncManager.java:
786:scheduleSyncOperation()] scheduleSyncOperation: dropping duplicate
sync operation authority: com.android.contacts account: Account
{name=username, type=com.example.android.samplesync} extras: []
syncSource: 2 when: 319845375 expedited: false
01-31 21:02:06.425: VERBOSE/SyncManager(206): [SyncManager.java:
786:scheduleSyncOperation()] scheduleSyncOperation: dropping duplicate
sync operation authority: com.android.contacts account: Account
{name=username, type=com.example.android.samplesync} extras: []
syncSource: 4 when: 319845416 expedited: false
01-31 21:02:06.425: VERBOSE/SyncManager(206): [SyncManager.java:
1473:handleMessage()] handleSyncHandlerMessage: MESSAGE_CHECK_ALARMS
01-31 21:02:06.425: VERBOSE/SyncManager(206): [SyncManager.java:
1473:handleMessage()] handleSyncHandlerMessage: MESSAGE_CHECK_ALARMS
01-31 21:02:06.435: VERBOSE/SyncManager(206): [SyncManager.java:
1473:handleMessage()] handleSyncHandlerMessage: MESSAGE_CHECK_ALARMS

On Jan 31, 6:00 pm, Dmitri Plotnikov <dplotni...@google.com> wrote:
> I cannot spot anything obviously wrong here.
>
> Here's what I would do in this situation:
>
> Plan A: Closely examine the logs - there might be something there already.
>  Enable more logging and see if you can glean anything from it:
>
> adb shell setprop log.tag.SyncManager VERBOSE
>
> Plan B: I would put aside the sync adapter that you wrote, take
> SampleSyncAdapter, make sure it works on the device, and then start morphing
> it into what you need, making small incremental changes and retesting until
> it stops working.  Then you know where you made a mistake.
>
> Plan C: I would get Android source and step through it in the debugger.
>  SyncManager is a complicated class, so it will take you a few minutes to
> figure out.  But in the end it's just Java.  If you can write Java, you can
> read Java.
>
> I hope this helps,
> - Dmitri
>
> On Mon, Jan 31, 2011 at 5:19 PM, himanshu jain <himanshu....@gmail.com>wrote:
>
>
>
>
>
>
>
> > this is my manifest file
>
> > <manifest xmlns:android="http://schemas.android.com/apk/res/android";
> >      package="org.c99.SyncProviderDemo"
> >      android:versionCode="1"
> >      android:versionName="1.0">
>
> > <uses-permission
> >        android:name="android.permission.GET_ACCOUNTS" />
> >    <uses-permission
> >        android:name="android.permission.USE_CREDENTIALS" />
> >    <uses-permission
> >        android:name="android.permission.MANAGE_ACCOUNTS" />
> >    <uses-permission
> >        android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
> >    <uses-permission
> >        android:name="android.permission.INTERNET" />
> >    <uses-permission
> >        android:name="android.permission.WRITE_SETTINGS" />
> >    <uses-permission
> >        android:name="android.permission.WRITE_SECURE_SETTINGS" />
> >    <uses-permission
> >        android:name="android.permission.READ_CONTACTS" />
> >    <uses-permission
> >        android:name="android.permission.WRITE_CONTACTS" />
> >    <uses-permission
> >        android:name="android.permission.READ_SYNC_STATS" />
> >    <uses-permission
> >        android:name="android.permission.READ_SYNC_SETTINGS" />
> >    <uses-permission
> >        android:name="android.permission.WRITE_SYNC_SETTINGS" />
>
> >    <application android:icon="@drawable/icon" android:label="@string/
> > app_name">
> >        <activity android:name=".LoginActivity"
> >                  android:label="@string/app_name">
> >            <intent-filter>
> >                <action android:name="android.intent.action.VIEW" />
> >            </intent-filter>
> >        </activity>
> >                <activity android:name=".ProfileActivity"
> >                                        android:label="Profile">
> >                        <intent-filter>
> >                                <action
> > android:name="android.intent.action.VIEW" />
> >                                <category
> > android:name="android.intent.category.DEFAULT" />
> >                                <data
> > android:mimeType="vnd.android.cursor.item/
> > vnd.org.c99.SyncProviderDemo.profile" />
> >                        </intent-filter>
> >                </activity>
> >                <service android:name=".AccountAuthenticatorService"
> >                        android:exported="true">
> >                        <intent-filter>
> >                                <action
> > android:name="android.accounts.AccountAuthenticator" />
> >                        </intent-filter>
> >                        <meta-data
> > android:name="android.accounts.AccountAuthenticator"
> >                                android:resource="@xml/authenticator" />
> >                </service>
> >                <service android:name=".ContactsSyncAdapterService"
> >                        android:exported="true" >
> >                        <intent-filter>
> >                                <action
> > android:name="android.content.SyncAdapter" />
> >                        </intent-filter>
> >                        <meta-data
> > android:name="android.content.SyncAdapter"
> >                                android:resource="@xml/syncadapter" />
> >                        <meta-data
> > android:name="android.provider.CONTACTS_STRUCTURE"
> >                                android:resource="@xml/contacts" />
> >                </service>
>
> >    </application>
> >    <uses-sdk android:minSdkVersion="5" />
>
> > </manifest>
>
> > thanks
>
> > On Jan 31, 4:53 pm, Dmitri Plotnikov <dplotni...@google.com> wrote:
> > > I would double-check every line of AndroidManifest.xml, compare it with
> > the
> > > one in SampleSyncAdapter to see if anything's missing.
>
> > > On Mon, Jan 31, 2011 at 4:26 PM, himanshu jain <himanshu....@gmail.com
> > >wrote:
>
> > > > @Dmitri
>
> > > > Yes i created my account when i go to Account & sync section through
> > > > settings and after adding my account , sync gets enabled in DDMS i can
> > > > see SyncManager gets called twice once on setIsSyncable and on
> > > > setSyncAutomatically but My Service associated with SyncAdapter does
> > > > not gets started and also i dont reach to onPerformSync immediately
> > > > when i explicitly call requestSync.
>
> > > > thanks
>
> > > > On Jan 31, 4:11 pm, Dmitri Plotnikov <dplotni...@google.com> wrote:
> > > > > Do you see your account in Settings/Accounts?   Does it have contact
> > > > syncing
> > > > > enabled?
>
> > > > > On Mon, Jan 31, 2011 at 2:44 PM, himanshu jain <
> > himanshu....@gmail.com
> > > > >wrote:
>
> > > > > > @Dmitri
>
> > > > > > thanks once again
>
> > > > > > But why my SyncService not gets started by SyncManager on Device i
> > > > > > dont know , and i explicitly call requestSync flow is not going
> > inside
> > > > > > onPerformSync.?
>
> > > > > > thanks
>
> > > > > > On Jan 31, 1:49 pm, Dmitri Plotnikov <dplotni...@google.com>
> > wrote:
> > > > > > > Sending requestSync to contentresolver is the right way to go if
> > you
> > > > want
> > > > > > an
> > > > > > > explicit button to request sync. This is what applications like
> > > > Calendar
> > > > > > and
> > > > > > > Gmail do when you push the "Sync" button.  ContentProvider will
> > also
> > > > > > request
> > > > > > > sync whenever there is a change in the data.
>
> > > > > > > You should query raw contacts that have the DIRTY flag set.
> >  These
> > > > are
> > > > > > the
> > > > > > > added, deleted or changed contacts.   Your sync adapter should
> > reset
> > > > this
> > > > > > > flag after syncing up changes.  It also needs to physically
> > remove
> > > > > > deleted
> > > > > > > contacts from the database.  In both cases it needs to supply the
> > > > > > > CALLER_IS_SYNCADAPTER query parameter - otherwise the protocol
> > won't
> > > > > > work.
>
> > > > > > > Cheers,
> > > > > > > - Dmitri
>
> > > > > > > On Mon, Jan 31, 2011 at 1:37 PM, himanshu jain <
> > > > himanshu....@gmail.com
> > > > > > >wrote:
>
> > > > > > > > @Dmitri
>
> > > > > > > > Thanks a lot for spending time to answer my questions at least
> > some
> > > > > > > > doubts are faded off.
>
> > > > > > > > 1) I understand to use own activity for editing and creating
> > new
> > > > > > > > contacts.
>
> > > > > > > > 2) Ok, if i avoid ContentObserver even i had that in mind might
> > > > > > > > require something to be running in background which is bad
> > agreed.
>
> > > > > > > > 3) But, there are two use cases first if there is a button that
> > say
> > > > > > > > sync now and i send request using requestSync() method will it
> > > > start
> > > > > > > > immediate sync via SyncManager or again it will depend upon
> > > > > > > > SyncManager discretion?? if thats true i cannot start immediate
> > > > > > > > Sync ??.
>
> > > > > > > >  Second use case how would i know if there is a change
> > > > corresponding
> > > > > > > > to my account in raw_contact utilizing best practice push
> > > > > > > > notification ?? so that i can trigger syncing.
>
> > > > > > > > thanks Dimitri for your time and ideas
>
> > > > > > > > On Jan 30, 11:42 am, Dmitri Plotnikov <dplotni...@google.com>
> > > > wrote:
> > > > > > > > > Hi Himanshu,
>
> > > > > > > > > 1) SampleSyncAdapter is still a good source of inspiration.
> >  It
> > > > has
> > > > > > some
> > > > > > > > > issues and plan to have them fixed in the nearest future.
>
> > > > > > > > > 2) In releases of Android from Eclair through Gingerbread
> > > > integrated
> > > > > > > > editing
> > > > > > > > > of 3rd party contacts is poorly supported.  The trick is to
> > > > insert a
> > > > > > data
> > > > > > > > > row, "Edit in MyApp", which would take the user to your app
> > and
> > > > your
> > > > > > app
> > > > > > > > > would then provide an editor activity.  Also, there is no
> > > > provision
> > > > > > in
> > > > > > > > the
> > > > > > > > > Contacts UI for creating new contacts in 3rd party accounts.
> >  We
> > > > have
> > > > > > > > fixed
> > > > > > > > > those issues in Honeycomb.  Now you can specify two
> > activities in
> > > > > > your
> > > > > > > > > metadata xml file: one for creating new contacts and one for
> > > > editing
> > > > > > > > > existing ones and voilà! - you have seamless integration.  Of
> > > > course,
> > > > > > > > it's a
> > > > > > > > > bit too soon to rely on Honeycomb as the dominant version of
> > > > Android
> > > > > > ;-)
> > > > > > > >  So
> > > > > > > > > for now you will need to either go with the described hack or
> > > > only
> > > > > > allow
> > > > > > > > > creation/editing of contacts through your app.
>
> > > > > > > > > 3) Please consider an alternative to using content observers
> > for
> > > > a
> > > > > > sync
> > > > > > > > > adapter.  There are several reasons:
>
> > > > > > > > > - In order to receive notifications, your process will need
> > to be
> > > > > > running
> > > > > > > > at
> > > > > > > > > all times. Or it would have to have a broadcast receiver,
> > which
> > > > is
> > > > > > very
> > > > > > > > very
> > > > > > > > > costly.
> > > > > > > > > - Content observer notifications are not reliable.  If your
> > > > process
> > > > > > is
> > > > > > > > not
> > > > > > > > > running at the time the change occurs, the notification will
> > > > never be
> > > > > > > > > delivered.  A broadcast receiver will solve that problem, but
> > > > please
> > > > > > > > don't
> > > > > > > > > use broadcast receivers for this!
> > > > > > > > > - Contacts
>
> ...
>
> read more »

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to