- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的代码
private static final LatLng AMSTERDAM = new LatLng(52.37518, 4.895439);
private static final LatLng PARIS = new LatLng(48.856132, 2.352448);
private static final LatLng FRANKFURT = new LatLng(50.111772, 8.682632);
private GoogleMap map;
private LatLngBounds latlngBounds;
private Button bNavigation;
private Polyline newPolyline;
private boolean isTravelingToParis = false;
private int width, height;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_navigation);
getSreenDimanstions();
map = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
bNavigation = (Button) findViewById(R.id.bNavigation);
bNavigation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isTravelingToParis)
{
isTravelingToParis = true;
findDirections( AMSTERDAM.latitude, AMSTERDAM.longitude,PARIS.latitude, PARIS.longitude, GMapV2Direction.MODE_DRIVING );
}
else
{
isTravelingToParis = false;
findDirections( AMSTERDAM.latitude, AMSTERDAM.longitude, FRANKFURT.latitude, FRANKFURT.longitude, GMapV2Direction.MODE_DRIVING );
}
}
});
}
@Override
protected void onResume() {
super.onResume();
latlngBounds = createLatLngBoundsObject(AMSTERDAM, PARIS);
map.moveCamera(CameraUpdateFactory.newLatLngBounds(latlngBounds, width, height, 150));
}
public void handleGetDirectionsResult(ArrayList<LatLng> directionPoints) {
PolylineOptions rectLine = new PolylineOptions().width(5).color(Color.RED);
for(int i = 0 ; i < directionPoints.size() ; i++)
{
rectLine.add(directionPoints.get(i));
}
if (newPolyline != null)
{
newPolyline.remove();
}
newPolyline = map.addPolyline(rectLine);
if (isTravelingToParis)
{
latlngBounds = createLatLngBoundsObject(AMSTERDAM, PARIS);
map.animateCamera(CameraUpdateFactory.newLatLngBounds(latlngBounds, width, height, 150));
}
else
{
latlngBounds = createLatLngBoundsObject(AMSTERDAM, FRANKFURT);
map.animateCamera(CameraUpdateFactory.newLatLngBounds(latlngBounds, width, height, 150));
}
}
private void getSreenDimanstions()
{
Display display = getWindowManager().getDefaultDisplay();
width = display.getWidth();
height = display.getHeight();
}
private LatLngBounds createLatLngBoundsObject(LatLng firstLocation, LatLng secondLocation)
{
if (firstLocation != null && secondLocation != null)
{
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(firstLocation).include(secondLocation);
return builder.build();
}
return null;
}
public void findDirections(double fromPositionDoubleLat, double fromPositionDoubleLong, double toPositionDoubleLat, double toPositionDoubleLong, String mode)
{
Map<String, String> map = new HashMap<String, String>();
map.put(GetDirectionsAsyncTask.USER_CURRENT_LAT, String.valueOf(fromPositionDoubleLat));
map.put(GetDirectionsAsyncTask.USER_CURRENT_LONG, String.valueOf(fromPositionDoubleLong));
map.put(GetDirectionsAsyncTask.DESTINATION_LAT, String.valueOf(toPositionDoubleLat));
map.put(GetDirectionsAsyncTask.DESTINATION_LONG, String.valueOf(toPositionDoubleLong));
map.put(GetDirectionsAsyncTask.DIRECTIONS_MODE, mode);
GetDirectionsAsyncTask asyncTask = new GetDirectionsAsyncTask(this);
asyncTask.execute(map);
}
}
MyLogCat
03-26 13:09:15.145: E/AndroidRuntime(389): FATAL EXCEPTION: main 03-26 13:09:15.145: E/AndroidRuntime(389): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.emildesign.navigationapplication/com.emildesign.navigationapplication.NavigationActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment 03-26 13:09:15.145: E/AndroidRuntime(389): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2249) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.app.ActivityThread.access$700(ActivityThread.java:154) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.os.Handler.dispatchMessage(Handler.java:99) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.os.Looper.loop(Looper.java:137) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.app.ActivityThread.main(ActivityThread.java:5306) 03-26 13:09:15.145: E/AndroidRuntime(389): at java.lang.reflect.Method.invokeNative(Native Method) 03-26 13:09:15.145: E/AndroidRuntime(389): at java.lang.reflect.Method.invoke(Method.java:511) 03-26 13:09:15.145: E/AndroidRuntime(389): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 03-26 13:09:15.145: E/AndroidRuntime(389): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 03-26 13:09:15.145: E/AndroidRuntime(389): at dalvik.system.NativeStart.main(Native Method) 03-26 13:09:15.145: E/AndroidRuntime(389): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment 03-26 13:09:15.145: E/AndroidRuntime(389): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:710) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.view.LayoutInflater.rInflate(LayoutInflater.java:752) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.view.LayoutInflater.inflate(LayoutInflater.java:495) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 03-26 13:09:15.145: E/AndroidRuntime(389): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:342) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.app.Activity.setContentView(Activity.java:1928) 03-26 13:09:15.145: E/AndroidRuntime(389): at com.emildesign.navigationapplication.NavigationActivity.onCreate(NavigationActivity.java:38) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.app.Activity.performCreate(Activity.java:5255) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2213) 03-26 13:09:15.145: E/AndroidRuntime(389): ... 11 more 03-26 13:09:15.145: E/AndroidRuntime(389): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4323000 but found 0. You must have the following declaration within the element: 03-26 13:09:15.145: E/AndroidRuntime(389): at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source) 03-26 13:09:15.145: E/AndroidRuntime(389): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source) 03-26 13:09:15.145: E/AndroidRuntime(389): at com.google.android.gms.maps.internal.q.B(Unknown Source) 03-26 13:09:15.145: E/AndroidRuntime(389): at com.google.android.gms.maps.internal.q.A(Unknown Source) 03-26 13:09:15.145: E/AndroidRuntime(389): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source) 03-26 13:09:15.145: E/AndroidRuntime(389): at com.google.android.gms.maps.SupportMapFragment$b.gW(Unknown Source) 03-26 13:09:15.145: E/AndroidRuntime(389): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source) 03-26 13:09:15.145: E/AndroidRuntime(389): at com.google.android.gms.dynamic.a.a(Unknown Source) 03-26 13:09:15.145: E/AndroidRuntime(389): at com.google.android.gms.dynamic.a.onInflate(Unknown Source) 03-26 13:09:15.145: E/AndroidRuntime(389): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290) 03-26 13:09:15.145: E/AndroidRuntime(389): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:682) 03-26 13:09:15.145: E/AndroidRuntime(389): ... 21 more
我的 list
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.emildesign.navigationapplication"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="com.emildesign.navigationapplication.permission.MAPS_RECEIVE" />
<permission
android:name="com.emildesign.navigationapplication.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.emildesign.navigationapplication.NavigationActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="ichangeditforyou" />
</application>
</manifest>
我的 Activity XML
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
<Button
android:id="@+id/bNavigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:text="Navigate" />
最佳答案
错误在这里:
The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4323000 but found 0. You must have the following declaration within the element
将此 xml 添加到您的 list 中:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
关于android - 致命异常 : main 03-26 > 13:09:15. 145 : E/AndroidRuntime(389): java. lang.RuntimeException: > 无法启动 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22671221/
我真的很难弄明白这一点。当我查看 logcat 指向错误的位置时,它指向这一行: throw new RuntimeException(i); 在里面 public void onDetach() {
@Transactional (noRollbackFor=RuntimeException.class) public void methodA (Entity e){ service.met
我正在开发简历应用程序并遇到以下异常 在gradle文件上,我尝试了所有可能的解决方案,使缓存重启无效,并且干净的gradle不起作用 java.lang.RuntimeException:java.
我的项目在 Android Studio 3.0.1 上的 Whatchap 中,这是我的设计 gradle。build.gradle(应用程序) 应用插件:'com.android.applicat
// Top-level build file where you can add configuration options common to all sub-projects/modules.
您好,目前我正在开发包括解析服务器的项目,并且在将解析库添加到我的项目后,当我运行它时,它显示此错误,任务“:app:checkDebugDuplicateClasses”执行失败。 Exec
我找到了 another post显示我们如何创建我们自己的检查异常,它也返回不同于 500 的 HTTP 状态代码。但是,我需要它是一个 RuntimeException。然后,我找到了WebApp
我尝试在 7.40 系统上演示具有动态方法名称的 CALL METHOD 语句。我使用下面的测试代码,在第 27 行得到一个 ABAP 运行时错误。异常描述中的错误分析状态 ... 在类 LCL 中,
我的ViewModel类抛出了RunTimeException。它基本上不能创建ViewModel类的实例。这是堆栈跟踪: 2019-05-29 01:27:56.700 9698-9698/com.
我安装了Hive 0.9.0,运行它时出现错误: ./hive Logging initialized using configuration in jar:file:/usr/lib/hive-0.
当我尝试在 android 4.1.1(galaxy nexus)上运行 opencv(2.4.2) sample3时。我收到RuntimeException。 Logcat指向此处:(android
Java中除了RuntimeException之外还有其他可能发生的异常吗?谢谢。 最佳答案 是的,有三种种。 检查异常 编译器会让您知道何时可以抛出它们,很可能是由于环境中的故障。 如果程序可以
这个问题已经有答案了: Why runtime exception is unchecked exception? (5 个回答) 已关闭 7 年前。 我知道受检查的异常继承自 Exception并且
这里发生了什么? 为什么 IOException (RemoteException) 的检查子级会转换为 RuntimeException? 摘自here的片段 import java.rmi.Rem
源代码(osmand)没有错误 我使用了 eclipse 和 sdk 模拟器 2.2,从 googlecode checkout (osmand应用程序) 我的代码: public void onCr
我开始研究线程,我不明白为什么下面的简单代码不起作用。它正在抛出: RuntimeException: can't create handler inside thread that has not
我想为自己破例。但是当我抛出异常时,程序就关闭了。那么我怎样才能运行我的方法3次然后关闭程序呢? (我的程序在intArray之后关闭,但我想遍历dobleArray和charArray) 这是我的异
我有一个扩展 HttpServlet 的类包含以下两个方法。当客户端向 Tomcat 服务器上运行的 Web 应用程序发出请求时,http 请求将通过此类处理,但是如果 doSomething 方法抛
在很多地方,我都会遇到几个检查异常,例如 IOException、ParseException、JSONException 等。我必须做出两个选择 - 通过在方法签名末尾添加 throws 来引发相同
RuntimeExceptions 应该指示编程错误,我希望我的应用程序在我的可观察对象中的某些东西抛出 RuntimeException 时崩溃。 最好的方法是什么?现在我正在考虑这个解决方案(它是
我是一名优秀的程序员,十分优秀!