[Xposed Framework Modules] MohammadAG:
Requires Xposed Framework!

This module adds an API to the Google Search app, commonly referred to as Google Now.

This allows developers to make plugins that react to searches done in Google Search.

As of right now, the developers cannot interact with the cards UI, not sure how feasible that is, if it is, it'll be in future versions.

(I showed this on reddit some days ago: http://www.reddit.com/r/Android/comments/1rmvxs/heres_a_preview_of_my_google_search_now_api/)

Screenshots:

Demos:

Lyrics fetching: https://www.youtube.com/watch?v=OsNCHo5JZuA

Song recognition outside US with Shazam: https://www.youtube.com/watch?v=ThbW5glU7zM

AutoVoice: http://www.youtube.com/watch?v=usjqq5hwlSE

Compatibility:

Any 4.1+ device that can run Xposed Framework. ICS not supported at the moment, not sure how recent the Google Search port is.

Download:

Please note that this is a 1.0 release, it may or may not have bugs.

http://repo.xposed.info/module/com.mohammadag.googlesearchapi

Source:

This is open source, you're free to contribute to the source, but you're in now way allowed to release this anywhere else.

https://github.com/MohammadAG/Google-Search-API

Plugins:

This doesn't do anything without plugins, which needs developer support. More on that below. Here are some fully working examples:

Music Controls: Control music playback. Supported commands: "play/pause/resume music", "play songs by <artist>", "play song <title>", "next/previous track/song", "volume up/down/max", "what song is this" opens in Shazam, requires Shazam, no idea what happens without it.

Voice Toggles: Turn on/off Wi-Fi, Mobile Data, or Bluetooth.

AZLyrics Viewer: Shows lyrics for songs from AZLyrics.com. Supported commands: "show lyrics for <song> by <artist>", exact syntax required here, artist is not optional.

Autovoice, by [MENTION=4805489]joaomgcd[/MENTION], run Tasker commands from Google Search.

Plugin sources:

Music Controls: https://github.com/MohammadAG/GNAPI-MusicControls

Voice Toggles: https://github.com/MohammadAG/GNAPI-VoiceToggles

AZLyrics Viewer: https://github.com/MohammadAG/Android-AZLyricsViewer

Developers:

Implementing plugins is as easy as copying one file to your source, and implementing a BroadcastReceiver that listens for the search queries (sent as text). If you're implementing a UI, implement TextToSpeech for voice feedback, if not, use GoogleNowApi.speak for voice replies.

All this is demonstrated in the examples above.

You'll also need to add a permission to AndroidManifest.xml: "com.mohammadag.googlesearchapi.permission.ACCESS_GGOGLE_SEARCH_API"

Remember that any package needs one activity to be started to work, see the music controls example for a way around that.

Of course, you're free to make your plugins free/paid/whatever.

What are the two checkboxes for?

If you're using GEL, you basically need to have the first checkbox checked. This is because GEL uses an overlay for the first part of the search, then opens the usual search app without the transitions. This means that if a developer already started an activity, it'll be sent to the background cause search was started after it.

Second checkbox prevents duplicate searches, this can be useful (you'll see how), and not so useful (when you do two volume ups/downs). Experiment as needed.

Support development

This took quite a lot of research, Google Search's code is huge, if you found this useful, please consider a donation.