我有一个由 editText 字段和按钮组成的应用程序。用户可以在该字段中输入一个地址,当他们按下按钮时,将创建一个调用 Google map 应用程序的 Intent 。
然后这会按预期加载,但由于某种原因,提供的地址找不到...
我不知道为什么。
在我的 XML 布局文件中引用 EditText。
address = (EditText)findViewById(R.id.addressBox);
从 EditText 字段中检索输入并启动一个新的 Intent。
String location = address.getText().toString();
location = location.replace(" ", "+");
Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + address));
startActivity(i);
非常感谢任何建议。
当我尝试查找地址时,谷歌地图按预期启动,并显示带有此错误消息的 Toast:
“未找到结果:android.widget.EditText 40d9fef8”
最佳答案
看起来您在 new Intent()
中传递编辑文本。再看看它我怀疑你的意思是 "geo:0,0?q="+ location
。
关于android - 通过 Intent 将信息传递给 Google Map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13057463/