I have gone through a number of links and have spend a huge amount of time over this. Can someone please let me know the simplest approach to implement the Sync Adapter in Android which is 2 way. I mean the changes made on the remote database get reflected on the Android Device and the changes from the device should get updated on the server too.
Also, how to edit the contacts from the default contacts app editor??
Related
I want to show the contacts whoever using my app. I know this is an old one but nothing satisfies me. I'm already using the method that gets all the contacts from phone and send to server and checking the available contacts who all are
using my app then return to my app.
Finally, it will save into the local database. But the problem is when adding new contact we have to sync again. For that time it will take more time and other functionality may become slow.
What I need is when I open the app at first time it should sync all the contacts and then it should monitor the changes like add, delete and update of the contacts then only it should check the changed contact.
I refers this blog, but there is no proper code. So many files are missed. How can i sync contacts?
finally,I have done with this library.
I have read every amount of detail on syncadapters that exists and I understand how it is meant to work, but I cannot find any information on if it is possible to NOT let the user unsync the data.
For example if I use the syncadapter to sync all of my data for my application with the server, obviously I would not want the user to be able to check "Don't sync data" from the accounts screen, so I want to know if there is a way to sync all of this data with the sync adapter either by not having the option to check the box to unsync, or by creating a hidden sync account that the user cannot modify.
If using the sync adapter is the wrong context for this case I would appreciate some examples of better ways to implement what I need or a heading in the right direction. I think using the syncadapter MAY be wrong and I may have to implement my own custom service, I just need a example or something to get me headed in the right direction.
Thank you for your help.
I found the solution, there is a tag you can specify in the xml layout
android:userVisible="false"
this allows the user to not have the option to uncheck syncing. Althought there is still a bug in 2.3.3 that says the service is not syncing, even though it IS syncing. Most likely because the user is not selecting a checkbox.
I am creating an app to backup contacts to a webserver. I am still new to android development so I can't think of the logic to do this. I know that the contact id is not constant and it can change. So how can I keep track of changed data to existing and new contacts?
You need to first grab the contacts in Android look at the example code in the AOSP project for the people app, that will show you the way that Google is doing it officially, which doesn't necessarily make it the best method, but it's a lot easier to re-tool their code than write it all from scratch.
Here's how to get started with the Android build environment:
http://source.android.com/source/initializing.html
Here's another question, similar to yours that might help with the contact data:
How to read contacts on Android 2.0
On your end, you need to setup a SQL server of some kind... and one of the fields just needs to be "Last Updated", either add a date to that field, or a revision number that you're tracking elsewhere and decide to update based on the query out of that field.
I'm trying to do a sync adapter to sync my contacts with an webstorage.
When I ask this server for any contactupdates on the server-side I get a list of all the new informations added/changed. To update them I'm using the preferred method described here
My problem is that when I make a ContactOperations.newUpdate() and feed it with all the new/changed informations I got from the webserver and then apply it to the ContactsContract.AUTHORITY all the informations already stored on the phone are erased?!?
I make an example to make thinks clear:
I have an contact saved on my phone named: John 'Dady' Doe. Now the SyncAdapter ist invoked by the system, he ask the server for any contactchanges and the server says, that the familyname of this contact now is "Jones". With that information I construct a new ContactProviderOperation.newUpdate() and feed it via .withValue() and apply it. But what Android really does is: It flushes all othere columns and now my contact is named "Jones" (givenName and middleName missing -.-).
Is there any way to prevent Android from doing so? Can I pass any parameter like the CALLER_IS_SYNCADAPTER? Or do I need to make my own workaround (hopefully not), like reading the data record first, apply the updates and then apply it to the ContactsContract.AUTHORITY?
Any hint is really appreciated!
/edit: I did further studies by looking at the SyncAdapterExample, especially at the "update a contact"-part, but what I saw kinda shocked me: Google actually does read the contact first, then apply the updates from the server and reapply it to the ContactsContract.AUTHORITY. But they only handle first- and lastname, one email and two phones (normal and mobile). In my case I wan't to handle ALL contactinformations, so it's not feasible to do such a workaround, except there is no other way, which I hope not. Hopefully someone can head me in the right direction for this.
Totally my fault :/
Android is doing everything right, I just failed as hard as this guy ...
I'm working on security application which will copy all contacts to some other database and delete all contacts from phonebook.
I'm testing this on android HTC HERO.
I'm successful to delete contacts from phonebook and create new contact info database,
Till 200 it is working, but after 200 contacts its not working properly.
After tht application starts throwing error.
There is one Sync with Google Option in Menu>Setting>Data Sync, I think that is creating problem.
There is notification that "Too many contacts deleted"
n if i click tht there will b a dialog with title "Delete Limit exceeded".
Is there anything i can do to stop syncronization or any other ideas by which i can achieve
required output?
Please Help me on this
Google Sync is a bit picky - it hates it when there are too many things going on. The calendar has the same problem. I doubt that you want to turn syncing off (the user may not appreciate it either if you turn off a core functionality). What's your goal? Do you want the deletion of contacts to be synced with gmail.com or not?
At this point, your only options as far as I can tell would be to throttle your app so it doesn't delete more than 200 records within a certain timeframe. Alternatively, you could use gdata to modify the contacts, but that's a really roundabout way and probably not suitable for your needs.
Do you delete and then re-create the contacts? Is there any way for you to recycle existing contacts instead of deleting them and then starting from scratch?