java - Android Studio ...在意图中将查询值传递给互联网搜索
问题描述
以下代码与 onClickListener 一起使用以打开 YouTube,并且应该传递查询值。
String Query = MOVENAME.toString();
Uri uri = Uri.parse("http://www.youtube.com/#q=" );
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.putExtra("query", Query );
startActivity(intent);
try {
this.startActivity(intent);
} catch
但是,它只会打开 YouTube……但如果我将其替换为……
intent.putExtra("query", "anything I want to search for" ); <-note text surrounded by " "
然后它会根据输入的文本运行搜索。
关于如何以可行的格式将存储在 MOVENAME 中的 EditText 信息传递给意图的任何建议?
解决方案
更正....字符串查询 = MOVENAME.getText().toString();
忽略了所需的 .getText() 并且传递的是对象而不是内容。
推荐阅读
- swift - 使用带有组合的 URLSession 的间歇性结果
- java - Spring Boot 与 AWS IoT api 的连接得到错误 403 被禁止
- python - 从查询集中获取唯一记录的最快方法
- html - 带有 html/css 的两行元素组
- elasticsearch - Elasticsearch - 查询关键字值
- c# - MongoDB .NET Core:使用 BulkWrite 找不到数组过滤器
- javascript - 通过复选框的 json 值
- spring-boot - :generateGitProperties git submodule Build FAILED in Heroku
- php - 使用 php yii migrate 命令时出现错误?
- c# - Ocelot RouteClaimsRequirement 无法识别我的声明并返回 403 Forbidden