Search dialog search suggestion - android

I have implemented search dialog and online search suggestion. But I want when user click on suggestion to copy string from suggestion list to search dialog and when user click on search button to start searching. Now when user click on suggestion searching is automatic start.

Take a look at http://developer.android.com/guide/topics/search/adding-custom-suggestions.html#RewritingQueryText which lists 3 different approaches to do this as per below:
1) Add the android:searchMode attribute to your searchable configuration with the "queryRewriteFromText" value. In this case, the content from the suggestion's SUGGEST_COLUMN_TEXT_1 column is used to rewrite the query text.
2) Add the android:searchMode attribute to your searchable configuration with the "queryRewriteFromData" value. In this case, the content from the suggestion's SUGGEST_COLUMN_INTENT_DATA column is used to rewrite the query text. This should only be used with URI's or other data formats that are intended to be user-visible, such as HTTP URLs. Internal URI schemes should not be used to rewrite the query in this way.
3) Provide a unique query text string in the SUGGEST_COLUMN_QUERY column of your suggestions table. If this column is present and contains a value for the current suggestion, it is used to rewrite the query text (and override either of the previous implementations).

Related

Android Find when the voice icon is clicked in a SearchView

I have been wracking my brains but have come up short. https://developer.android.com/training/search/setup.html I am trying to figure out how to find out when the user has clicked on a voice button or for that matter what the user has said. This is independent of what the user types on a searchview. So, the https://developer.android.com/reference/android/widget/SearchView.html#setOnSearchClickListener(android.view.View.OnClickListener).. will not work.
Other than extending the SearchView and putting in my own click listener is there a way for me to find out when the user has clicked on the voice icon?
Just like any search, the result is found in SearchManager.QUERY. However, for voice search, SearchManager.USER_QUERY will be empty as per its documentation:
Intent extra data key: Use this key with content.Intent.getStringExtra() to obtain the query string typed in by the user. This may be different from the value of QUERY if the intent is the result of selecting a suggestion. In that case, QUERY will contain the value of SUGGEST_COLUMN_QUERY for the suggestion, and USER_QUERY will contain the string typed by the user.

How to get Recently Added / Edited / Deleted contact from Phonebook in android

I making an application in which my requirement is to get the Recently Added or Edited or Deleted Contact in Phonebook. So is there is way to achieve this. Any help will be appreciated.
You need to show what you tried, so that we can write our answers based on your try.
First, make sure you have this:
<uses-permission android:name="android.permission.READ_CONTACTS" />
According to the android docs, you can easily read contacts, and, to get specific selections (which is exactly what you want) you can:
Define a search text expression that retrieves rows for a specific
contact's LOOKUP_KEY and the Data.MIMETYPE of the details you want.
Enclose the MIMETYPE value in single quotes by concatenating a "'"
(single-quote) character to the start and end of the constant;
otherwise, the provider interprets the constant as a variable name
rather than as a string value. You don't need to use a placeholder for
this value, because you're using a constant rather than a
user-supplied value.
Take a look at the different ways to get specific selection keys on contacts, so that you can get exactly what you want.
http://developer.android.com/training/contacts-provider/retrieve-details.html

Android - how to create custom word dictionary for only my application?

I have successfully added a word to Android's predefined user dictionary, but i want to create a custom dictionary which can only be accessed by my application.
For example: When i type "lol", the suggestions show me "laugh out loud" but when I want another meaning of "lol" then I can manually add another meaning of "lol" (eg, "xxxxxx" - so the next time the user writes "lol" in an EditText, the suggestions will show him "xxxxxx").
No other application should have access my dictionary data.
I have worked with spell checker class but it gives me only correct word and I can't my own word meanings.
Please give me some suggestions or links.
There is an Androids inbuilt class UserDictionary so that you can add your spells programmatically into that, Here is a link you can go through with , and which may relates to your problem .(In this solution nidhi has manged programmatically to retrieve data back)
Add word to user dictionary and retrieve them back from dictionary
In addition you can go through following links to :
http://developer.android.com/reference/android/provider/UserDictionary.html
http://developer.android.com/reference/android/provider/UserDictionary.Words.html
Moreover if you want a custom personal dictionary then manually you have to store words and retrieve them back .
Hope that helps !!!

Android App , add a favorite quote functionality

I have an android app which displays quotes and have navigation to go to next quote and so on. would like to add "Save Quote As favourite" based on users selection of particular quote.
Once user saves Fav quotes and wants to see those quotes only, app should show those quotes.
Currently app reads the quotes from XML file. Let me know if any more information is required to understand the problem.
I would provide every quote with an ID (int). Whenever the user selects a quote to be a favourite, that ID is saved to a Set of integers. Later on if user decides to show favourites, you fetch all quotes with your IDs from the Set and show them in a appropriate view, for example a ListView
If you have a Quote class or something like that, you might as well put them in a collection whenever user decide his favourites, and show them in a ListView with a custom adapter.

Using text field with AdapterView

Is it possible to use AdapterView with text fields in android?
My query returns a set of values and for each I want to place that within a textfield, so that the user may edit the value.
Also, I want to click a button to create a new empty field, so that I may insert a new entry.
If you know of good example, then please let me know!
EDIT 1
I would prefer to use XML to define ui and I found this informations:
"In this case we create a new id called text1. The + after the # in the id string indicates that the id should be automatically created as a resource if it does not already exist, so we are defining text1 on the fly and then using it." Source http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html
Will this + allow me to autocreate as many fields as needed? Is there a way I can generically specify the layout in XML and then create fields adhoc based on db response?
Many thanks,
Mith
Is it possible to use AdapterView with
text fields in android?
Yes. It will be complex for you (and possibly also for the user), so I would not recommend it unless you have a few months' Android programming experience, but it should work.
Also, I want to click a button to
create a new empty field, so that I
may insert a new entry.
That will get a little complicated.
Will this + allow me to autocreate as
many fields as needed?
No, that is not how you use ListAdapters for ListView rows.
Is there a way I can generically
specify the layout in XML and then
create fields adhoc based on db
response?
Use a CursorAdapter.
Here is a free excerpt from one of my books that describes creating custom adapter classes. Here is a sample project that shows creating a custom CursorAdapter to display the results of a database query.

Categories

Resources