I have a few questions about the concept of androids timestamps. I want to synchronize my contacts but only if the timestamp of the contacts detail in the android is older than that one in my database.
My questions. Is there a timestamp for each detail like phonenumer, emailaddress and address. And who to check it? I tried it for ContactsContract.CommonDataKinds.Phone.STATUS_TIMESTAMP which is always null.
Any ideas? The Android Api tells me that there should be a timestamp (long).
Thanksfor your help.
There isn't. The field you're talking about is a convenience for someone who wants to stamp the row with the last time the raw contact's status was updated. I doubt that the Android system itself is using it.
I think that Contacts synchronization assumes that Google Contacts is the source of all knowledge, and the Android system is just a reflection of it. If something changes on Android, and it hasn't changed in Google Contacts, then it gets uploaded to Google Contacts. Changes on Google Contacts overwrite anything on Android.
On the whole, I'm suspicious of synchronization based on timestamps, because it has a tendency to get screwed up.
Are you trying to replace the google.com sync adapter with your own? You're a brave person!
CONTACT_LAST_UPDATED_TIMESTAMP
is added in the API 18. The same can be used.
Related
Hi everyone i'am currently developing an android game, it uses your phone number when you first use the game(it is for an identification of the user).
It is an social game at some time when the user requests it returns a list of people who are currently online(playing the game),as json array(there phone number,name,photo)and from the data received you need to filter it out and display in two list views. The filtering done by this method:
1)Each element from JSON data(each person)if there phone number is found in user's contact list then is displayed in the first listview
2)if the number is not found in users contact list it is displayed in second listview.
But my doubt is that if the JSON array returns details of 10 people, you need to check for this 10 people whether they are in user's contact list.And does this kind of a technique takes a lot of time and creates delay in the UI..?
If yes please suggest me some other method.
Also please tell me how can I check whether a number is in user's contact list(I make the users upload there number to server without any country code).
So please in the number finding method you need to end the checking one a number has been fully completed.(starting from the end.
eg : 8086934565 (no saved in database) +918086934565(no in contact list)
then we need to start from last so that
5==5 then continue
6==6 then continue
till any of the no (+918086934565 or 8086934565) ends without breaking any equivalent condition.
eg for numbers +918086934565 and 8086933365
checking from the last
5==5,6==6, 5!=3 there the equivalent condition goes wrong and hence it should get out from the loop with a flag ie the numbers are not equal.
Please write me the function to do this or tell me an alternative method.
Any help would be appreciable.
Thanks.
Ugh, that's painful to read...haha...You're suggesting using phone numbers to identify users in a multiplayer matchmaking scenario? That's taboo...If you return a JSON array of users phone numbers, names, and photos, your app will almost certainly be permanently banned from the market and possibly your entire account. That is about the biggest security risk that I can possibly think of, you might as well have a textfield where everybody types in their social security number and it posts it to craigslist. Basically any of your users could just repeatedly initiate games with people and get names photos and phone numbers of 10 random people at a time by capturing the plain text JSON data coming back. If I were you I'd look into the facebook sdk for authentication or Google Play Game Services for multiplayer matchmaking unless the core mechanics of your game rely on phone numbers specifically, in which case by it's very nature is just not going to fly with users. Asking someone to write you a function to do that is most likely never going to happen on stackoverflow. I'm not even going to get into the last part of the question...This has to be a troll attempt...lol
I have a requirement like, I can be able to find the people who are using a particular app from my contacts. It is much similar like Whatsapp contacts syncing.
Whatsapp contacts is so fast & very accurate. What is the logic for it?
I'm not sure of their exact logic, but a way that I have seen it done before is as follows...
Access the phone's contacts (duh)
Get the contact that you want to add as a "friend" in your app.
Cross reference that contact's phone number with the user information that you have stored in your application's database
If that phone number exists in your database of users, then you've got a match and you can process things however you'd like from there.
That's one way of doing it, but I don't know if that's exactly how WhatsApp does it. Hope this helps!
I want to let my app scan the users contactlist , and display the name of the contacts who also installed the app.
I have no idea where to begin with this . so if someone could help me getting started , that would be apreciated.
grtz
You will need to research ContentResolver because you will have to query the database containing the contacts. To do these queries, you will need the URI and column/header names for contacts db which can be found in the Contacts class.
You will also need users to register that they have your app on your own servers and the registration will need a piece of information about the user that other users would have in their contacts (the users phone number, email address, etc).
You will then need to query a few users at a time from the users contacts for this piece of information (using the ContentResolver and Contacts class), pass it to your server (as text) where it will check if they are registered, then send a message back to initial user (and possibly the match) that you found a match.
That's where you should start, and end :)
Note, you will need these permissions in the Manifest file:
android.permission.INTERNET
android.permission.READ_CONTACTS
First of all, welcome to StackOverflow. StackOverflow is for programming questions. As is such, a post asking for help should always provide a description of what you have already tried. If you haven't tried anything yet, I highly encourage you to try something, and post when you encounter a problem.
As your question stands now, we don't know what the problem is. Are you having problems scanning a contact list? Or are you having problems trying to figure out if another user has installed the app?
That being said, you will have to maintain a database for your app containing a list of people who have installed your app. When your app is launched on one device, do whatever you need to do to register the user in your database. Due to the nature of a "contact," one person's phone may only have their phone number, email address, or even just a name. This is of course something you will have to deal with in your implementation.
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 ...