如何使用 Java 在 Android 中获取 Google 搜索结果? [英] How to get Google search results in Android using Java?

查看:28
本文介绍了如何使用 Java 在 Android 中获取 Google 搜索结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的 Android 应用中添加 Google 搜索功能.我想创建一个布局,我可以在其中显示来自不同分支(书籍、视频、地图等)的结果.如何以编程方式获得结果?任何 API 和示例?

I want to add Google search functionality to my Android app. I want to create one layout where I can display results from different branches (Books, Videos, Maps, etc). How can I get results programmatically? Any API and samples?

推荐答案

Google 网页搜索 将是您正在寻找的 API.

Google Web Search would be the API that you are looking for.

在搜索请求中,如果您进行基于位置的搜索,您可以在文本中指定纬度和经度以获取对附近地点的引用.此处是对搜索请求参数的引用.

In the search request, you can specify a latitude and longitude with the text to get a reference to the nearby places, if you are doing a location based search. Here is the reference to the parameters for the search request.

您可以简单地进行 http 调用并在返回时解析 JSON 响应.

You can simply make a http call and parse the JSON response when it comes back.

但是,CustomSearch 是 Google 鼓励您改用的新 API已弃用的.

However, CustomSearch is the new API that Google encourages you to use instead of the deprecated one.

这篇关于如何使用 Java 在 Android 中获取 Google 搜索结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆