How do I open the Search interface? - android

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.

Related

Facebook provider unconfigured. Make sure to add a `facebook_application_id` string

I'm using Firebase UI Sign In and trying to implement Facebook sign in into my android app. When launching the firebase ui activity I get:
"java.lang.IllegalStateException: Facebook provider unconfigured. Make sure to add a facebook_application_id string"
In my string resources I have added it, this is how it looks:
By the way in the firebase docs the string names are different from the ones in the facebook docs, this is how they look in the facebook docs or also called quickstart:
`<string name="facebook_app_id" translatable="false">SOMECODE</string>
<string name="fb_login_protocol_scheme"
translatable="false">SOMECODE</string>`
This is how it looks in the firebase docs:
<string name="facebook_application_id"
translatable="false">YOUR_APP_ID</string>
<string name="facebook_login_protocol_scheme"
translatable="false">fbYOUR_APP_ID</string>
I was also having some merging problem and fixed it by adding tools:replace="android:value" to the metadata and yes everything was added inside the application tags
<meta-data android:name="com.facebook.sdk.ApplicationId"
tools:replace="android:value"
android:value="#string/facebook_app_id"
/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
I don't know what's causing these problems but I think it has something to do with the string names, if anyone can help me please I will immensely appreciate it. Thank you!
Add Facebook Provider in Manifest as mentioned here.
Append your app id to the end of the authorities value. For example if your Facebook app id is 1234, the declaration looks like:
<provider android:authorities="com.facebook.app.FacebookContentProvider1234"
android:name="com.facebook.FacebookContentProvider"
android:exported="true" />
Use this is AndroidManifest.xml
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/FACEBOOK_FB_APP_ID" />
and in strings.xml
<string name="FACEBOOK_FB_APP_ID">{application id}</string>
Alright I was thinking that the strings provided by firebase and the ones provided by facebook where the same and I had to have only a pair of them, the truth is that they are different and add the ones provided by firebase and facebook to your string resources, that will solve the problem.

How to make my app accept search intents from other apps?

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.

How to add my app into the google local search?

In the android we can see that there is a default "google search" on the launcher. And I found out that using setting, we can set the searchable items. For example amazon kindle, music, or browser.
The question is, how can I add my app into the searchable items in the google search? Are there any APIs I can use?
Exactly, the first thing you do is provide a searchable.xml resource to Android. How this is done is described here.
Next, you have to declare an Activity to be searchable in your Manifest, like so:
<activity android:name="...">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="#xml/searchable" />
</activity>

Where can I find documentation when coding in Eclipse?

Then writing XML as manifest, how can I find documentation for things like intent-filter or action? Can I somehow display information on this in Eclipse without visiting developer.android.com like I can see the JavaDoc in Eclipse?
<activity android:name=".Activity1"
android:label="Activity1">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In Eclipse just press Ctrl+Space and you will get descriptions of elements.
Just make sure you're opening your manifest with the Manifest editor (right click on manifest -> open with -> Android Manifest Editor). Anyway why not use the GUI editor? You have tips there as well.
A good start: http://developer.android.com/guide/topics/manifest/manifest-intro.html

how to implement search box in my application in android?

i have one activity in my android application in which a list of orders is populated. I want to implement a search functionality on this activity so that user can search for particular order.
I have read about the search box facility provided by adding a searchable.xml file in the application but I am not able to make it work for me?
I just want to add a search box in the activity and search for specific data in database.
How can I do this?
#VNVN I would agree - I would review the developer guide. http://developer.android.com/guide/topics/search/search-dialog.html
You will need to make your activity search-able in the AndroidMainfest.xml file
<activity android:name=".MySearchableActivity" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="#xml/searchable"/>
</activity>
You are probably missing creating a SearchableActivity. http://developer.android.com/guide/topics/search/search-dialog.html#SearchableActivity

Categories

Resources