我有一个文本框,用户在这里输入文本,我想知道如何处理这个文本框,所以当用户输入文本,它打开谷歌搜索页面和搜索文本,我不想要使用apis,只需在浏览器中打开google网站并搜索文本即可。打开谷歌搜索页面
感谢
我有一个文本框,用户在这里输入文本,我想知道如何处理这个文本框,所以当用户输入文本,它打开谷歌搜索页面和搜索文本,我不想要使用apis,只需在浏览器中打开google网站并搜索文本即可。打开谷歌搜索页面
感谢
这里是一个解决方案:
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
String term = "TechnoTalkative"; // term which you want to search for
intent.putExtra(SearchManager.QUERY, term);
activity.startActivity(intent);
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
String term =tb.getText.toString();<-- get from your textbox(tb)
intent.putExtra(SearchManager.QUERY, term);
activity.startActivity(intent);
如果你想直接打开导航仪,你可以这样做:
String search = "what is android or something";
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com/#hl=eng&output=search&q="+ search));
startActivity(browserIntent);