Quick overview of deep search
On Android, you can send search queries to other apps via the intent mechanism. i.e., app X can direct a user to, let's say, Evernote, and perform a search within Evernote without exposing any data to app X.
Why is this useful? Because it's in essence a more secure deep link; regular deep links require an app to expose some data from app X, whereas deep search doesn't require any data to be exposed.
How it applies to us
From the beginning, WhereDat was built to utilize both deep links and deep search. We built it that way because it's the fastest way to search, allowing our app to search both your phone content and the content inside your apps. That's the cool part.
The not-so-cool part is that deep search seems too complicated for most mainstream apps to support it properly.
Let's use the example of Joe trying to do a deep search.
Joe types something in his phone’s search bar and selects the option which directs his query into another app; Joe is now performing what we call a "deep search."
Now, two things can happen to Joe. Either (a), the deep search works great (yay!) and Joe is happy, or (b), the search doesn't work and Joe is left thinking WhereDat was created by an iOS intern developer.
What messed up Joe's experience is an app he had installed on his phone told WhereDat it could accept deep search, but didn’t support it (probably because the target activity didn’t handle the search intent correctly).
How to fix it:
To enable this secure deep searching and allow other apps to send a search query to one of your activities simply follow these steps:
1. Add the "action.SEARCH" filter to your activity in AndroidManifest.xml:
<activity android:name=".SearchResultsActivity"> <intent-filter> <action android:name="android.intent.action.SEARCH" /> </intent-filter> </activity>
2. Handle the query sent from other apps:
public class SearchResultsActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { handleIntent(getIntent()); } @Override protected void onNewIntent(Intent intent) { handleIntent(intent); } private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); //use the query to search your data somehow } } }
That's it!
Make sure you handle the new query both onNewIntent and onCreate, as shown in the example. Many developers miss that, which explains most of the bugs found within "deep search."
Having trouble? Comment below or e-mail me and I'll help you out. :)