on 2012 Apr 05 12:54 PM
Hello,
My android application has a working mobilink synchronization, but is started only with a button click. I have to make my app synchronize in a period of time and I wonder what is the best approach to do this? Maybe a service with a running timer that calls the sync or it is better to try push notification.
Request clarification before answering.
Thanks for the answers, I made it using AlarmManager, because the Timer has problems when the phone goes into sleep mode. The processor slows down and the timer doest'n execute as it is scheduled.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
MobiLink has several options for Server Initiated Synchronization (SIS) and for Android you can also use Google C2DM to push synchronizations.
Unlike the SQL Anywhere client for MobiLink (dbmlsync), UltraLite has no built-in feature for scheduled synchronization but it does have support for performing background synchronization.
So changes on the consolidated database could start synchronization via SIS or C2DM, and you could have your Android application initiate a synchronization for changes made by it. Then there would be no need for scheduled synchronizations.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
FYI, some documentation may suggest otherwise but SIS is supported for Android.
In addition to Graham's valid answer, if you do want to do scheduled synchronizations (for example to save the performance drain of doing synchronizations after many updates in a short time interval) there are several options. One thing I do not recommend is doing a potentially long-running operation like synchronization on the UI thread (such as a button click). A couple of options are: (1) you could use java.util.Timer to run scheduled synchronizations on a thread. (2) you could use android.os.AsyncTask to run synchronizations on a background thread.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
50 | |
9 | |
8 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.