Android Auto-sync with custom data - android

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.

Related

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

How to provide content to be shown on Google-Now-On-Tap?

Background
I work on an app that can answer to certain queries (phone number queries, and maybe others).
Google introduced a new feature on Android 6 , called "Google Now On Tap" (AKA "Assist API") , which allows the user to query about things that are shown on the screen (triggered by long-click on home button or by saying something) without the need to type anything.
Google provided a developers tutorial for it, here
The problem
I can't find any code snippet to show how to prepare the app for it.
Only thing that I've noticed is that I can extend from Application class, and add OnProvideAssistDataListener inside , and register to it.
But, it opens a lot of questions about how to do it.
Sadly, because this topic is so new, I can't find almost anything about it, so I'd like to ask the questions here.
The questions
1) Is there any sample or at least a more explained tutorial for this new feature?
2) It is said in the docs:
In most cases, implementing accessibility support will enable the
assistant to obtain the information it needs. This includes providing
android:contentDescription attributes, populating
AccessibilityNodeInfo for custom views, making sure custom ViewGroups
correctly expose their children, and following the best practices
described in “Making Applications Accessible”.
Why and how does it work with the accessibility features of the app? What does it have anything to do with exposing child views (or views at all)? How could it even be about views, if the app doesn't run yet (because the feature is activated on any app, anywhere).
What I think is that this is called only if the foreground app is my app, but if it is this way, how can I actually offer queries that appear for all apps, depending on what the input is?
3) Does the class that extends from Application supposed to implement OnProvideAssistDataListener ? If so, why does it need to register to it? If not, how could it be that Google-Now-On-Tap works with it? It can't just open all apps that have such a classs, and see if they register...
4) The docs have a sample snippet which I didn't understand:
#Override
public void onProvideAssistContent(AssistContent assistContent) {
super.onProvideAssistContent(assistContent);
String structuredJson = new JSONObject()
.put("#type", "MusicRecording")
.put("#id", "example.comhttps://example.com/music/recording")
.put("name", "Album Title")
.toString();
assistContent.setStructuredData(structuredJson);
}
What does the new feature do with each key? Is it used by the app, or Google-Now-On-Tap ? What are my options about it?
Is this where I define if my app can handle the content that the feature suggests me? Is AssistContent supposed to be the input that I look at, and decide if my app can handle it or ignore it?

Android contacts custom field

Is it possible to add custom field to some contacts, with custom mimetype (like facebook profile) without writing sync adapter, authenticator and sync service? I do not want to add "synchronization" functionality for my application.
After long research I think that I found an answer to this question.
There is no way of creating custom clickable and visible fields without writing some Synchronization service code, authenticator and syncAdapter.
Here is sample code which is adding new account to "Accounts and synchronization", and adding new contact with custom field, which can be viewed in some activity from current project:
https://github.com/nemezis/SampleContacts.
Android does support syncing custom fields 'out of the box' if you use Gmail.
You can use Gmail in the browser to add custom fields to any contact. This field will then sync to the phone.
However, to view or edit these on the phone, you will need to use some new applications.
I wrote an article that describes this process. Gmail's Contacts Custom Fields and Android.

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.

Integrating application with default in android

I am currently writing an application which performs a search operation requested by the server at a pre-defined server location. Now , i need to integrate this application into the default Search that is provided on the Android Device i.e.. it should appear as an option for the user to perform his search ... like there are options to search the web , android market etc.. So , i should have my app also besides this ...
I am in a fix as to how to do this. Any suggestions, help of any kind , links to tutorials , articles are highly appreciated.
Thank You
You are in need of Suggestion Provider, you can explore this and if i remember correctly, the user needs to explicitly add your app to the search list. (It doesn't happen automatically)
http://developer.android.com/reference/android/content/SearchRecentSuggestionsProvider.html

Categories

Resources