[英]`ACTION_WEB_SEARCH` launching search action in Google app
I was trying to launch an Intent
which will launch a browser and search query on Google. 我试图启动一个
Intent
,它将启动浏览器并在Google上进行搜索查询。 But the problem is that it is directly launching the search query on Google app instead of any browser. 但是问题在于它是直接在Google应用而不是任何浏览器上启动搜索查询。 I have tested this on emulator and also in my Android device.
我已经在模拟器和Android设备中对此进行了测试。
My Approach : 我的方法:
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY,queryText);
startActivity(intent);
you can open browser using below intent 您可以使用以下意图打开浏览器
try{
String escapedQuery = URLEncoder.encode("Android developer", "UTF-8");
Uri uri = Uri.parse("http://www.google.com/#q=" + escapedQuery);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}catch (Exception e){
e.printStackTrace();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.