1
최근에 안드로이드 프로젝트가 Google Maps에서 ESRI ArcGIS로 전환되었고 현재 나는 전환 과정에 있습니다. 그 이후로 내가 직면 한 하나의 작은 문제가 있습니다.안드로이드를위한 ArcGIS LocationService 예외
다음 코드는 기본 위치 서비스를 사용할 때마다 NullPointerException
을 던집니다. LocationService.start() 호출이 try-catch 블록에 있는지 아니면 다른 스레드에서 실행되는지는 중요하지 않습니다. 응용 프로그램이 충돌합니다. 내가 잘못합니까 무엇
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): java.lang.NullPointerException
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at com.esri.core.geometry.Envelope.<init>(Unknown Source)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at com.esri.core.map.LayerModel.setExtent(Unknown Source)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at com.esri.android.map.LayerView.onSizeChanged(Unknown Source)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at android.view.View.setFrame(View.java:7123)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at android.view.View.layout(View.java:7050)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at com.esri.android.map.MapView.onLayout(Unknown Source)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at android.view.View.layout(View.java:7056)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at android.view.View.layout(View.java:7056)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at android.view.View.layout(View.java:7056)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at android.view.ViewRoot.performTraversals(ViewRoot.java:1049)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at android.view.ViewRoot.handleMessage(ViewRoot.java:1744)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at android.os.Handler.dispatchMessage(Handler.java:99)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at android.os.Looper.loop(Looper.java:143)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at android.app.ActivityThread.main(ActivityThread.java:5068)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at java.lang.reflect.Method.invoke(Method.java:521)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-13 10:08:55.580: ERROR/AndroidRuntime(28355): at dalvik.system.NativeStart.main(Native Method)
:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_esri);
map = (MapView) findViewById(R.id.map);
map.setExtent(boink);
map.setOnStatusChangedListener(new OnStatusChangedListener() {
private static final long serialVersionUID = 1L;
@Override
public void onStatusChanged(View source, STATUS status) {
if(status == STATUS.INITIALIZED) {
//set up location service
/*
* The following block throws exception and the application crashes.
* And it doesn't matter whether I run it from another thread or in a try-catch block!
*/
new Handler().post(new Runnable() {
@Override
public void run() {
try {
locationService = map.getLocationService();
locationService.setLocationListener(MapEsri.this);
// locationService.setAccuracyCircleOn(true);
// locationService.setBearing(true);
// locationService.setAutoPan(true);
locationService.start();
}
catch(Exception e) {
e.printStackTrace();
}
}
});
}
}
});
}
이 그것을 던져 예외는 :
다음은 Activity
클래스의 조각인가?
위치에 대해 자체 리스터를 만들어야합니다. 청취자를 구속 했습니까? locationService.setLocationListener (MapEsri.this); –