Android sync without content provider - android

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.

Related

How to implement both flexible and immediate In-App Update

How Do I implement both flexible and immediate in-app update in app at once and how do i set which type of update i want the user to see.
I found a solution for this problem which I have implemented for my project, I am using an API to send me if I want to give immediate or flexible update and based on that I have used if-else to run the desired code.
It is up to the user to decide which type of UPDATE they want.
It can also be configured via the remote config variable to decide which type of update they want.
It always returns true whether update type is FLEXIBLE or IMMEDIATE
isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)
isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
I have already integrated in-app update API in Many Mobile Application and It is running all perfect now. The documentation had this ambiguity.
So you should write your own logic whether you want Flexible or Immediate Update via remote config or server.

Android: Adding SyncAdapters to existing Account

I want to split up functionality from a bigger SyncAdapter to the corresponding Apps. Therefore i now have a single App which contains the Authenticator and a SyncAdapter which syncs core data.
The plan is now, that other Apps also contain SyncAdapters which sync the app-specific data.
Reading https://www.captechconsulting.com/blogs/android-single-account-multiple-application-prescription i tried to add a second adapter like suggested but i'm having the issue that it doesn't show up in the Account's SyncAdapter list.
UPDATE: just figured out that i used the same contentAuthority in the two SyncAdapter declarations (as i only have a single contentProvider) and of course same account-type which leads to a identical declaration and this could be the problem that my second syncadapter just overrides my first one.
still investigating this theory
as already mentioned in the update - the cause was the identical declaration.
you have to use a different contentAuthority (ContentProvider) for each SyncAdapter to get this working!

Listening for updates with RESTful APIs

I have a messenger app that makes GET /conversations requests to populate a list of the conversations of the user.
The next step is to make it "listen" for updates so that it marks conversations that have been updated and add conversations that have been created.
Should I use the same /conversations resource to get the updates or should I rather have a separate resource for that? Perhaps, something like /conversationUpdates.
It depends on whether you want to follow RESTful conventions. Many client side libraries such as backbone and extjs have fairly deep support for declaring a resource with a URI and then using the different HTTP methods (GET, POST, DELETE, etc.) against it. This might sometimes lessen the work clients need to do and folks will be grateful.
Following the convention will also make your api less surprising. There are undoubtedly other conventions for API's and not every domain space is well modeled with REST.
Rereading your post, I see you want to have an api that that just gets new posts. What constitutes new? New since the last time the client called the end point? In such instances an api might accept a parameter like the last identifier that had been received (if you are using something like a auto increment field, or a mongodb id). In that case you would just use the /conversations endpoint, with an extra parameter.
Firstly, I'd stick here with the GET method, since this is exactly the point: getting data.
As for the resource name, I'd go with the same, specifying it further in the query, something like /conversations?state=new. My point here is that the resource itself is still the same but you only want a subset of it.
However, if you plan on updating other things than conversations, you can use /updates/conversations since in this case, an update can be considered as a resource, itself composed of, among other things, conversations.

Piwik tracking in an android application

I want to do data analytics for my android application using Piwik.
In Piwik's documentation, they suggest using GitHub.
I got the Piwik API and download the following file:
https://github.com/piwik/piwik-java-tracking
which I don't know how to use.
What are the steps needed to get the data analysis using the Piwik working?
What should I do next?
I also would like to implement piwik tracking in my android app.
This is what I understood so far:
Unlike for iOS/MacOS applications, there is currently no SDK to help us out.
Piwik developers have a ticket opened in their bugtracker about this, which shows they're aware of the issue and willing to improve the situation, but it will take some time before this android tracking SDK is released.
At the moment, the Piwik team encourages android and Java developers to use the piwik-java-tracking library you mentioned. This is basically just a java wrapper for the web tracking API reference, which helps you to generate Tracking Request URLs to send to your Piwik instance.
This piwik-java-tracking project lacks documentation (there is none that I know of in Github), but there is javadoc in the java files.
Basically what you need to do to track an action is to:
Create a new instance of SimplePiwikTracker
Feed it with whatever values and parameters you wish to track using the various setters available
When you're done, get the URL using one of the methods defined in the PiwikTracker interface, depending of the type of "event" you want to track
Send a request to that URL to actually track your action into you Piwik instance.
This has several drawbacks:
If you need bulk tracking, you'll have to figure out a way of doing so. The web tracking API reference states you can use use a HTTP POST request containing a JSON object to do it.
It doesn't provide any help to handle the case where user is offline. If you need to, you'll have to find a way to cache your tracking request (in an sqlite database for example) and bulk send them when the user is back online.
You'll need to handle possible exceptions raised by network error for the tracking request, to make tat tracking does not interfere with your app normal behavior.
Be sure to read this article too. It gives you an overview of what you need to do to get up & running.
This is what I understood so far. I may update this answer as I progress in implementing piwik tracking in my own app.
Good luck.
Edit: I just noticed that Piwik released "Piwik SDK Android". There are some instruction on how to get this working in the project's wiki.

Android Syncadapter not let user choose to sync or not sync

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.

Categories

Resources