I'm trying to add my app to the global search in Android so users can search my app from their homescreen. I've followed the tutorial at http://developer.android.com/guide/topics/search/search-dialog.html but it won't seem to work. When I test the app and go to the part of the settings where you see all the searchable apps my app doesn't show up. Here's some of my code:
The Mainfest:
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
This of course is within the tag.
searchable.xml (res/xml/searchable.xml):
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:includeInGlobalSearch="true"
android:voiceSearchMode="showVoiceSearchButton"
android:label="Holo Wikipedia Search"
android:hint="Search Wikipedia" >
</searchable>
Please leave a commment if there's any more you want to see :)
Did you try using string resources for the label and hint?
Instead of hard-coded strings, try something like this:
android:label="#string/label_string"
android:hint="#string/hint_string"
Related
I have created a custom account_type (com.axonsystem.kangoosave) and is working fine. Also when I create contacts under this account_type programatically, in the Contacts Application (when I edit the contact) Android shows correctly my custom type.
This is my sync-adapter
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="com.android.contacts"
android:accountType="com.axonsystem.kangoosave"
android:userVisible="true"
android:allowParallelSyncs="false"
android:isAlwaysSyncable="true"
android:supportsUploading="false" />
And my service providing the SyncAdapter
<service
android:name="com.axonsystem.kangoosave.services.AccountSyncService"
android:exported="true"
android:enabled="true"
android:process=":sync">
<intent-filter>
<action android:name="android.content.SyncAdapter"/>
</intent-filter>
<meta-data android:name="android.content.SyncAdapter"
android:resource="#xml/syncadapter"/>
<meta-data android:name="android.provider.CONTACTS_STRUCTURE"
android:resource="#xml/contacts" />
</service>
My account-authenticator
<?xml version="1.0" encoding="utf-8"?>
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="com.axonsystem.kangoosave"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:smallIcon="#drawable/ic_launcher"
android:accountPreferences="#xml/account_preferences"/>
Now I want that my custom-type appears in Contacts Activity when creating a new contact (like google accounts and so on), even in the menu of "Contacts to display". Is it poosible ? Do someone have some information about that? I'm not able to get success in this point..
Thank you in advance
My first guess is that you'll have to change android:supportsUploading="false" in your sync-adapter xml to android:supportsUploading="true", otherwise the account may be considered being read-only (that's how it was handled in Android 2.x and I think that might be still the case).
Also it's important that your xml/contacts file defines a non-empty contacts schema, check out test_basic_contacts.xml for a complete example. An empty EditSchema basically means that no fields can be edited, which means the account is read-only as well (hence you can't create contacts).
I am trying to dd my application the "Accounts Section" of the settings. So that when the user clicks on Add account , my app name is visible. The complete code can be found here
I have created an authenticator service. This is how my manifest looks like
<service android:name=".AuthenticatorService">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator"
android:resource="#xml/authenticator" />
</service>
I also created an "authenticator.xml"
<?xml version="1.0" encoding="utf-8"?>
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="com.udinic.auth_example"
android:icon="#drawable/ic_launcher"
android:smallIcon="#drawable/ic_launcher"
android:label="testing"
android:accountPreferences="#xml/prefs"/>
But still I dont see my app under accounts. I am following this tutorial
but its not working. Can you tell me what am I doing wrong ?
Use a resource string instead of using literal text in label.
"authenticator.xml"
android:label="#string/some_label"
My searchable activity currently looks like this in the Android Manifest:
<activity
android:name=".activity.Search"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>
I would like to be able to add my application to the preinstalled "Google Search"-app as a searchable element and therefore accept its search intents.
Seems correct. Did you enable your app in the Google-Search app settings, to be searchable?
I just found this page on the android dev blog. What I've been missing was the xml attribute android:includeInGlobalSearch="true" in my searchable.xml.
I've been following the Searchable Dictionary example pretty carefully as I'm trying to implement the search functionality in my app. Right now I simply can't seem to get the Search interface to open when I press the search button. I've added the following into my manifest and searchable.xml resource into my res folder (which I pretty much copied from the example).
<activity android:name=".main.SearchActivity"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>
<meta-data android:name="android.app.default_searchable"
android:value=".main.SearchActivity" />
What I'm not understanding is what else do I need to do to get this to work? Is there something I should have hard coded? Thanks a lot!
Nevermind, I realized that in the searchable.xml, you can't use static strings, they have to be from the strings.xml resource. I just had to create search_label and search_hint and refer to them in the searchable.xml file. Here's the original article on that.
Is it possible to alter the Search Dialog (prior to Android 3.0) on my Activity? This is the search bar that drops down when you press the hardware search button. By alter, I mean modify the layout. I'd like to add an additional button to it if I could.
I think floating search box is what you want ~
It's not difficult but its configuration is a little more complicated~
First you need configure parameter of the search bar
new a searchable.xml profile like this:
<searchable xmlns:android=http://schemas.android.com/apk/res/android
<!-- label is the text at the bottom of the search bar,hint is the text in the search bar -->
android:label="#string/search_label"
android:hint="#string/search_hint"
android:searchMode="showSearchLabelAsBadge"
<!-- voice search -->
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
android:voiceLanguageModel="free_form"
android:voicePromptText="#string/search_invoke"
<!-- Configure search suggestions-->
android:searchSuggestAuthority="com.android.cbin.SearchSuggestionSampleProvider"
android:searchSuggestSelection=" ? "
/>
you should do this in the mainfest.xml:
<activity android:name="SearchResultActivity">
<intent-filter>
<action android:name="android.intent.action.SEARCH"></action>
</intent-filter>
<!-- searchable.xml -->
<meta-data android:resource="#xml/searchable"
android:name="android.app.searchable"></meta-data>
</activity>
<!-- For each Activity can use search bar,
be sure to start the label into the Activity
in which the value is the search results-->
<meta-data android:name="android.app.default_searchable"
android:value=".SearchResultActivity"
/>
<provider android:name="SearchSuggestionSampleProvider"
android:authorities="com.android.cbin.SearchSuggestionSampleProvider"></provider>
then override the onSearchRequested function of Activity
almost like this ,forget the details ~。~!!!
Good luck~