package com.example.myapplication;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.View;
import net.daum.mf.map.api.MapPoint;
import net.daum.mf.map.api.MapPolyline;
import net.daum.mf.map.api.MapReverseGeoCoder;
import net.daum.mf.map.api.MapView;
import java.util.Vector;
public class CreateCourseActivity extends AppCompatActivity implements MapView.CurrentLocationEventListener, MapReverseGeoCoder.ReverseGeoCodingResultListener {
private MapView mapView;
private Vector<PolylinePoint> vector = new Vector<>();
private MapPolyline polyline = new MapPolyline();
private long updateCount = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.i("CreateCourse.onCreate", "Start");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_course);
final CameraPreview surfaceView = (CameraPreview) findViewById(R.id.preview);
SurfaceHolder holder = surfaceView.getHolder();
holder.addCallback(surfaceView);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mapView = (MapView) findViewById(R.id.map);
mapView.setCurrentLocationEventListener(this);
mapView.setCurrentLocationTrackingMode(MapView.CurrentLocationTrackingMode.TrackingModeOnWithHeading);
mapView.setZoomLevel(4, true);
Log.i("CreateCourse.onCreate", "End");
}
@Override
protected void onDestroy() {
super.onDestroy();
mapView.setCurrentLocationTrackingMode(MapView.CurrentLocationTrackingMode.TrackingModeOff);
mapView.setShowCurrentLocationMarker(false);
}
@Override
public void onReverseGeoCoderFoundAddress(MapReverseGeoCoder mapReverseGeoCoder, String s) {
}
@Override
public void onReverseGeoCoderFailedToFindAddress(MapReverseGeoCoder mapReverseGeoCoder) {
}
@Override
public void onCurrentLocationUpdate(MapView mapView, MapPoint currentLocation, float accuracyInMeters) {
Log.i("CurrentMap.onChange", "Start");
MapPoint.GeoCoordinate mapPointGeo = currentLocation.getMapPointGeoCoord();
Log.i("Tag", String.format("MapView onCurrentLocationUpdate (%f,%f) accuracy (%f)", mapPointGeo.latitude, mapPointGeo.longitude, accuracyInMeters));
polyline.addPoint(MapPoint.mapPointWithGeoCoord(mapPointGeo.latitude, mapPointGeo.longitude));
updateCount++;
PolylinePoint point;
point = new PolylinePoint(mapPointGeo.latitude, mapPointGeo.longitude, updateCount);
vector.add(point);
mapView.addPolyline(polyline);
Log.i("CurrentMap.onChange", "End");
}
@Override
public void onCurrentLocationDeviceHeadingUpdate(MapView mapView, float v) {
}
@Override
public void onCurrentLocationUpdateFailed(MapView mapView) {
}
@Override
public void onCurrentLocationUpdateCancelled(MapView mapView) {
}
public void CreateCourseEnd(View view) {
Log.i("CreateCourse.End", "Start");
Intent intent = new Intent(this, CreateCourseEndActivity.class);
startActivity(intent);
finish();
Log.i("CreateCourse.End", "End");
}
}
현재위치를 나타내는 mapview와 카메라 surfaceview를 포함한activity에서 버튼 클릭시 전환되는 엑티비티의 mapview에 움직인 polyline을 표시할 계획입니다. 기존에 mapview는 fragment로 엑티비티에 표현했지만 버튼클릭시 종료가 되는 문제점을 해결하고자 엑티비티에 모두 포함시켰습니다. 하지만 아직 문제점은 해결이 안됬습니다. 어떤 도움이라도 주시면 감사하겠습니다.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.myapplication, PID: 25605
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.CreateCourseEndActivity}: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2857)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2935)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1627)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:6724)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
Caused by: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.myapplication.CreateCourseEndActivity.onCreate(CreateCourseEndActivity.java:14)
at android.app.Activity.performCreate(Activity.java:7028)
at android.app.Activity.performCreate(Activity.java:7019)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2810)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2935)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1627)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:6724)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
Caused by: java.lang.RuntimeException: DaumMap does not support that two or more net.daum.mf.map.api.MapView objects exists at the same time
at net.daum.mf.map.api.MapView.init(MapView.java:409)
at net.daum.mf.map.api.MapView.(MapView.java:464)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.myapplication.CreateCourseEndActivity.onCreate(CreateCourseEndActivity.java:14)
at android.app.Activity.performCreate(Activity.java:7028)
at android.app.Activity.performCreate(Activity.java:7019)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2810)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2935)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1627)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:6724)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)