http://goo.gl/EaVN

We recently launched Voice
Actions<http://googleblog.blogspot.com/2010/08/just-speak-it-introducing-voice-actions.html>
in
the new Google Voice Search for Android — an awesome new way to search,
control, and communicate on your phone faster than ever before, by using
your voice.

One of these new Voice Actions lets users find and automatically play music.
By speaking something like “listen to They Might Be Giants” into the new
Voice Search, users can quickly find the music they want online and play it,
using any number of different apps. (Pandora<http://www.pandora.com/android>
, Last.fm <http://www.last.fm/hardware/android>,
Spotify<http://www.spotify.com/int/mobile/android/>
, mSpot <http://www.mspot.com/music/learn_mobile>, and
Rdio<http://www.rdio.com/apps/mobile/> are
among the first apps to support this.)

To do this, we leveraged a very common little piece of Android magic: a new
Intent <http://developer.android.com/reference/android/content/Intent.html>.
If you develop a music app that supports open-ended music search, you can
make it work with users speaking “listen to” Voice Actions simply by
registering for the new intent we’ve defined. This new intent isn’t defined
as a constant in the SDK yet, but we wanted to make sure music app
developers had all the information needed to use it right away.

Here’s all you should need to know:

   -

   In your AndroidManifest.xml, just register one of your activities for the
   new intent android.media.action.MEDIA_PLAY_FROM_SEARCH:

   <application android:label="@string/app_name" android:icon="@drawable/icon">

       <activity android:name="MusicActivity" android:label="@string/app_name">

           <intent-filter>
               <action
android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />

               <category android:name="android.intent.category.DEFAULT" />

           </intent-filter>
       </activity>
   </application>

   -

   When your activity receives this intent, you can find the user’s search
   query inside the
SearchManager.QUERY<http://developer.android.com/reference/android/app/SearchManager.html#QUERY>
string
   extra:

   import android.app.Activity;
   import android.app.SearchManager;

   public class MusicActivity extends Activity {

       @Override
       public void onCreate(Bundle savedInstanceState) {

           super.onCreate(savedInstanceState);

           String query = getIntent().getStringExtra(SearchManager.QUERY);

           // Do something with query...
       }
   }

   This will represent everything the user spoke after “listen to”. This is
   totally open-ended voice recognition, and it expects very flexible
   search — so, for example, the string could be the name of any artist (“they
   might be giants”), an album (“factory showroom”), a song (“metal detector”),
   or a combination of any of these (“metal detector by they might be giants”).

A few subtle details worth understanding about this intent:

   -

   Your app should do its best to quickly find and *automatically play* music
   corresponding to the user’s search query. The intention here is to get users
   to their desired result as fast as possible, and in this case, that means
   playing music quickly.
   -

   This will really only work well for music apps that can find music across
   a very large corpus of options. Because our voice recognition doesn’t
   currently support any way to provide a list of specific songs to be
   recognized, trying to use it against a small set of music choices will work
   poorly — things which are not in the set will be over-recognized, and things
   which are in the set may not be recognized well. So if you’re not the
   developer of a large-scale cloud music application, this intent is probably
   not for you.

We think you’ll find this new intent can greatly enhance your music app’s
experience for users. And we hope you enjoy our new Voice Actions as much as
we do!
-- 
Salam,


Agus Hamonangan

http://groups.google.com/group/id-android
http://groups.google.com/group/id-gtug
Gtalk  : id.android
Follow : @agushamonangan
E-mail :  [email protected]

-- 
"Indonesian Android Community [id-android]" 

Join: http://groups.google.com/group/id-android/subscribe?hl=en-GB  
Moderator: [email protected]
Peraturan Jual dan Kloteran ID-Android  http://goo.gl/azW7
ID Android Developer: http://groups.google.com/group/id-android-dev
ID Android Surabaya: http://groups.google.com/group/id-android-sby
ID Android on FB: http://www.facebook.com/group.php?gid=112207700729

Kirim email ke