Open browser at specified URL using ACTION_VIEW does not work when chrome is the default browser

I have 2 browsers installed on your Android device 1) by default and 2) Chrome

When I run the following code, I get a "Full action using" selector ...

String url = "http://www.google.com/search?q=" + query; 
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

The Android browser works by default, since the browser opens at the specified URL. However, when I open the Chrome browser, Chrome just opens ... it seems to ignore the specified URL.

Is this a problem with Chrome or my code?

Greetings

+5
source share
1 answer

The problem was my query variable. It looks like Chrome did not accept the query string format in which the default Android browser was installed.

, URL- ...

query = URLEncoder.encode(query, "UTF-8");
+2

All Articles