Android Syncadapter not let user choose to sync or not sync - android

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.

Related

Firebase database structure - storing user activity in order to customize views and permission

Working with Firebase for the first time and looking for advice of setting up the right structure for my project which is basically an "offers/coupon" type starter project.
The scenario is this:
I have a node containing a list of all offers available to users
This list of offers is displayed to users after successful Firebase authentication
When a user redeems an offer, I want to be able to count/record that activity in their child node under user and hide that offer so that they cannot see it again once used.
My question is what would be the best way to do this given that offers may be added, may expire, or may change at some point in the future. So, in effect, the user should receive the list of most updated offers, minus the ones he/she have used in the past.
a) would it be more effective to have a master list of offers, and then run a cloud/server function to clone this list for each new user an track that way
Firebase Structure 1
or
b) Keep a master list of offers in one node, then track user specific offer usage
Firebase Structure 2
Appreciate your guidance
The second solution is better because you'll save bandwith. This practice is called denormalization and is a common practice when it comes to Firebase. The first solution is not good becase every time you want to display the users you donwload unnecessary data. If you want to read more details about how you can structure a Firebase database in a efficient way, please read this post, Structuring your Firebase Data correctly for a Complex App. Also, you can take a look a this tutorial, Denormalization is normal with the Firebase Database, for a better understanding.
Second solution is much good. Because in first one we are having redundancy of data in our database. And second one obviously removing that cause.
But instead of using true or false because it is only showing you, "it's available or not", so you can use a string type parameter as "expired", "going to expire" and "updated" or whatever sooo. So it. Will be able to trace all you information related to offer for particular user. I think this is your requirement also.
Happy coding.

Is It possible to add my application in account?

I am trying to add my application in account same as Gmail and whatsapp do.I did lots of search but no luck.
I want something like this:
Stackoverflow isn't a place where you just ask how is something done and expect to get an answer. You have to show what you've tried and what isn't working.
As for your question, applications only appear in the account list if the application is performing some sort of data synchronisation between the app and a server. Therefore you would need to create a sync adapter.
Below are two links that show how to do this
Android Dev Guide - Creating a Sync Adapter
Tutorial for creating your own sync adapter
Hope this helps

Two way sync adapter in Android

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??

Android Auto-sync with custom data

Situation: I have an account for my application that I created following the example code at http://developer.android.com/resources/samples/SampleSyncAdapter/index.html. When clicking on the account from the Account & Sync Settings screen, I see a "Sync Contacts" checkbox. When this checkbox is active, my custom sync successfully runs in the background.
Problem: I'm not syncing contacts, I'm syncing the application's custom data. I would like the checkbox to say something like "Sync Historic Data"
Question: Does anyone know where I can find some documentation on how to do this, or what steps I need to take that I can search for documentation for? Any advice or keywords to help broaden/guide my search would be appreciated as well.
Just add a custom android:label attribute to the definition of your content provider in AndroidManifest.xml.
Here is a nice basic tutorial covering the basics on the SyncAdapter.

Android sync without content provider

I use a service to check for stuff on the server, and wanted to transition that to use the standard android sync capability. However, the config file confuses me.
android:contentAuthority
android:accountType
android:supportsUploading
I don't know what these represent and don't have any meaningful values for them. It seems like I'll need a content provider to use the sync, but that's not how I implemented everything.
Any good links or info on implementing sync with your own code?
You can implement anything you want for your sync needs. Android sync adapter provides a framework for sync'ing which includes states, callbacks, settings, scheduled events, etc. You can use what you need and leave the rest for other apps. There are helper functions that makes it easy to use consistently with the syncing that you find in Accounts & Sync Settings.
The android:contentAuthority is the unique identifier used during the broadcast that your sync adapter would respond to. It is like "com.mycompany.myproject. ...". The flag android:supportsUploading is required for permission to send data out of your application. I believe it is coordinated with some android:uses-permission setting.
I don't think you are required to have a CP, but quite often you would and if you do, it can be really thin to be the authority.

Categories

Resources