URI链接在浏览器上无法通过意图打开。

问题描述 投票:1回答:1

我的目的不是打开和显示 FatalException 错误。我要求浏览器打开链接,但无法打开,找不到这个 error.

public void searchQuestion(View view) {
    String queryString = search_input.getText().toString();

    Log.d(TAG, "searchQuestion: "+ search_input.getText());

    Uri buildURI = Uri.parse(BASE_URL).buildUpon()
            .appendQueryParameter(QUERY_PARM, queryString)
            .build();
    Log.d("buildURI", "getBookInfo: " + buildURI);

    Uri uri = Uri.parse(String.valueOf(buildURI));
    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH, uri);
    startActivity(intent);
}
android android-intent uri
1个回答
1
投票

使用 ACTION_VIEW 而不是 ACTION_WEB_SEARCH.

Uri uri = Uri.parse(String.valueOf(buildURI));
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(intent);

更多信息 https:/developer.android.comreferenceandroidcontentIntent#ACTION_WEB_SEARCH。

© www.soinside.com 2019 - 2024. All rights reserved.