[英]Get Google search results and show in android app
我想在我的Android應用程序中顯示google搜索結果,當用戶在editText中鍵入word並單擊搜索按鈕以獲取google搜索結果並顯示在我的應用程序內部。我沒有這樣做的經驗。 請任何人幫助我
您可以在行動網頁搜索中使用Intent
類。
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
String keyword= "your query here";
intent.putExtra(SearchManager.QUERY, keyword);
startActivity(intent);
為了更好地學習,您可以按照示例程序進行操作。
您可以在此處找到所有詳細信息: https : //developers.google.com/custom-search/json-api/v1/overview?refresh=1 ,但最終您一天只能免費推送100個查詢,其余的,您必須為每1000個查詢支付5 $。
或者我已經為您找到了以下鏈接,請告訴它是否可行:
private static final String GOOGLE_SERACH_URL = "https://www.google.com/search?q=";
然后,只需在URL后面附加要在Google上搜索的關鍵字,然后將查詢字符串加載到WebView中即可。
webView = (WebView) rootView.findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(GOOGLE_SERACH_URL + searchKey);
工作實例
https://github.com/hiteshsahu/Android-Universal-Web-Content-Loader
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.