[英]toast cannot be resolved and activitynotfoundexception cannot be resolved to a type
我想在我的应用程序中导入Google地图。
这是代码:public static void maps(活动活动,字符串地址){
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?q=" + address));
activity.startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(activity, activity.getString(R.id.webView), Toast.LENGTH_SHORT).show();
}
}
public static void navigation(Activity activity, String address) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + address));
activity.startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(activity, activity.getString(R.id.webView), Toast.LENGTH_SHORT).show();
}
}
我得到2个错误。 无法将ActivityNotFoundException解析为一种类型,并且无法解析Toast。
这怎么可能?
谢谢
这是因为缺少导入语句。通过在Eclipse中按ctrl+shift+o
来导入这些程序包。或在标头部分中添加这些程序包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.