SyncAdapter and Syncing contacts on application server - android

I was searching for a way to sync contacts to my application server and I stumbled across SyncAdapter. I'm new to the concept, so here's my question:-
How does WhatsApp/Facebook/Hike applications create account in Settings>Account section of the android device? Is this related to the SyncAdapter? If yes please provide appropriate explanation or some link to the same as to how should I implement this.
Ultimately, I want to sync my contacts to the application server on user registration, and also update the database whenever user adds/updates the contacts on the device. I'm stuck on this for a long time now so any help would be highly appreciated! Thanks

There's an older blog post that demonstrates the account and sync aspects. Even though it is old the content is still relevant to what you need.
http://www.c99.org/2010/01/23/writing-an-android-sync-provider-part-1/
https://github.com/c99koder/AndroidSyncProviderDemo

Get the contact sync project from here.This code works fine.
If you want more details refer follow the links,
1.http://udinic.wordpress.com/2013/07/24/write-your-own-android-sync-adapter/
2.http://developer.android.com/training/sync-adapters/creating-sync-adapter.html
If you want to sync periodically, then use background services using Timer.

Related

Is it possible to connect to microsoft outlook scheduling assistant from an android app?

I am trying to build an application which requires the information from microsoft outlook scheduling assistant.
Okay, this is a huge question! Simple answer, no, there is no easy way to just plug it in, but that doesn't mean it isn't possible. Let's assume you're using the exchange server, you can create a request that returns you the availability info of a list of contacts over a period. This returns an array of integers detailing the status of that person during each hour/half hour of the period you sent.
You can then make a table layout with views depicting their availability with different colors. This is not an easy task. I recently had to do it for my company's email client and it took about 3 days of pretty hardwork to get a good looking UI with all the information you need.
For information on the protocols you send to get the availability info, check out the documentation here. If you need any help doing this, please feel free to comment here. Unfortunately, I can't share the code I wrote, since I wrote it while working for IBM

Syncing a REST service with an android app

There's a REST service that I use to populate info in my database, that is later used by my app.
I've read several threads on the matter, and now have to decide how I want the sync between the REST service and my DB to work.
Think of an app that gets info from google finance APIs about stocks and stores it in a DB, displays the information when the app is launched, and sends notifications when specific events happen in the stock price.
I already implemented the simple option of AsyncTask that is launched when a user manually requests a sync. Now I have to implement the auto-sync and these are the options I found:
Create a Service that will do the syncing
Use a Sync Adapter / Sync Provider
So I found a lot of advantages to the second option, particularly those explained in this video, but also two major disadvantages:
I couldn't find good documentation for android sync (a few third party articles such as these, but no official Google or Android Developers guide)
According to this article messing up in a Sync Adapter can cause major issues such as OS crash and reboot.
Most of the info I found is pretty old, so maybe things have changed since, but my App is supposed to work with API level 8 and above, so I would be very thankful for any recommendations and links to valuable documentation.
Definitely go with SyncAdapter. Follow instructions here: Why does ContentResolver.requestSync not trigger a sync?.
To do SyncAdapter, you'll also need to make an Account/AccountAuthenticator as well, so your SyncAdapter knows how to login to your service -- Unless it truly is the Google Finance APIs, in which case all you need to do is apply the right permissions in the manifest so that it will use the account settings already on the phone.
You didn't link the article you mentioned that discussed crashes, but I know it, and it's actually talking about Accounts -- Which yes, you do need to be careful with.
Checkout https://github.com/sschendel/SyncManagerAndroid-DemoGoogleTasks.
Demonstrates setting up sync of Google Task API data to local SQLite db.

How can i get notifications from server to android device?

I am creating a app wherein user shares some information. This data i am storing it in database through servlets i.e. i am calling my own servlets which will take data through url and store it in database. So i want other users of that same app to get notify that some information is available and in turn they will get the information that other user has updated.
For this to work we can use polling or pusher. But polling will take lots of battery power.
I have tried C2DM but its not working for me. So i am thinking for some other mechanism by which i can implement other than C2DM.
Please suggest some way to work it. and e.g. if u have came across.
C2DM is deprecated, the new version is called Google Cloud Messaging (GCM) and is exactly what you need for your use case. There is even a GCM Demo Application which uses a Java servlet. The source code can be found here, you browse it directly or if you prefer GitHub you can use this repository.
The servlet code can be found in the file
samples/gcm-demo-server/src/com/google/android/gcm/demo/server/HomeServlet.java
If you follow the instructions in the Getting Started guide you will soon have a working application. I would suggest you not trying to copy paste it together, you have to get a clear understanding of how the GCM architecture is working.

Android How to fetch yahoo Contacts

i want to fetch the yahoo contacts from my android app, if i click the button it has to ask for log in to yahoo, after successful logging in we can able to fetch the contacts, is there any way to do like that or any sample code, please guide me, thanks in advance.
Check out http://developer.yahoo.com/social/contacts/ and sign up as a developer.
http://developer.yahoo.com/social/rest_api_guide/ysp_api_book.html For some more information.
Regarding to examples, there really are tons and tonnes of them out there. Either use their rest service directly or implement the SDK available at: http://developer.yahoo.com/social/sdk/index.html

Notification in Android

I am trying to create an android application which allows users to receive updates from a particular server/website.
For example, whenever I have a piece of information I want to share, like an update or notice, I will post it on this website. Whenever, there are updates posted by me, I want the phone to receive a notification about it as well and add the information into the app.
Just like the gmail app on android. Update immediately when there is a mail and not have a timer to check at every interval.
Does anyone know how can I go about it? I am new to programming, it will be good if your answers in steps for me to follow. Thanks in advance.
EDIT:
The android application will have a login page which is define the type of the user. Only the updates and information regarding the type of the user will be pushed.
However users of this application, may not login with a google account.
You could use C2DM - Cloud 2 Device Messaging. It's relatively new tech though so not a lot of resources about it.
Here's a good tutorial on it: http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html
Edit: PS: and it's in beta too so might work best as a proof of concept more than an actual product.

Categories

Resources