将Google Search API添加到Android应用

时间:2013-10-21 11:07:26

标签: android google-search-api

您好我想将谷歌搜索API添加到我的应用程序中。搜索结果应该显示在列表视图中...任何人都可以给我发送一些示例或告诉我该怎么做?

2 个答案:

答案 0 :(得分:3)

这是:

import android.app.SearchManager;

// ...

Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);  
intent.putExtra(SearchManager.QUERY, "Search query");    
startActivity(intent);

基于语音的搜索:

import android.speech.RecognizerIntent;

// ...

Intent sp = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
sp.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
sp.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speak please");
startActivity(sp);

答案 1 :(得分:2)

以下是在Android应用中实施Google搜索的一个很好的示例Implementing google search 希望它有所帮助。