这是我的代码。我尝试了这段代码,但我在MapActivity,MapView和其他位置都有错误。当我把光标放在那里时我写这段代码时它没有显示导入选项...我不知道为什么。任何尝试使用此代码的方法都不会在此处导入..检查出来plz
package com.bened;
import android.os.Bundle;
public class mapExactDemoActivity extends MapActivity {
/** Called when the activity is first created. */
MapView mv;
double lat=17.441966,lon=78.445127;
GeoPoint gp;
MapController mc;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mv=(MapView)findViewById(R.id.map);
gp=new GeoPoint((int)(lat*1000000),(int)(lon*1000000));
mc=mv.getController();
mc.setCenter(gp);
mc.setZoom(20);
mv.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.google.android.maps.MapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="00S4pru3FgTKZjOlX2agvv2TBWx5p3sVbOvgiAw"
android:clickable="true"
/>
</LinearLayout>
3.LogCat错误详情
11-23 12:02:03.946: D/PackageParser(68): Scanning package: /data/app/vmdl-1317076106.tmp
11-23 12:02:04.084: D/PackageManager(68): Scanning package com.bened
11-23 12:02:04.084: E/PackageManager(68): Package com.bened requires unavailable shared library com.google.android.maps; failing!
11-23 12:02:04.084: W/PackageManager(68): Package couldn't be installed in /data/app/com.bened-1.apk
11-23 12:02:04.234: D/dalvikvm(68): GC_EXPLICIT freed 580K, 49% free 4250K/8263K, external 4768K/5461K, paused 138ms
11-23 12:02:04.374: D/AndroidRuntime(360): Shutting down VM
11-23 12:02:04.384: D/dalvikvm(360): GC_CONCURRENT freed 213K, 71% free 302K/1024K, external 0K/0K, paused 2ms+1ms
11-23 12:02:04.394: D/dalvikvm(360): Debugger has detached; object registry had 1 entries
11-23 12:02:04.414: I/AndroidRuntime(360): NOTE: attach of thread 'Binder Thread #3' failed
11-23 12:02:33.943: D/SntpClient(68): request time failed: java.net.SocketException: Address family not supported by protocol
11-23 12:07:33.973: D/SntpClient(68): request time failed: java.net.SocketException: Address family not supported by protocol
11-23 12:07:52.414: D/AndroidRuntime(376): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
11-23 12:07:52.414: D/AndroidRuntime(376): CheckJNI is ON
11-23 12:07:53.496: D/AndroidRuntime(376): Calling main entry com.android.commands.pm.Pm
11-23 12:07:53.764: D/dalvikvm(236): GC_EXPLICIT freed 10K, 54% free 2546K/5511K, external 1625K/2137K, paused 88ms
11-23 12:07:53.787: W/ActivityManager(68): No content provider found for:
11-23 12:07:53.814: W/ActivityManager(68): No content provider found for:
11-23 12:07:53.864: D/PackageParser(68): Scanning package: /data/app/vmdl-257441530.tmp
11-23 12:07:54.024: D/PackageManager(68): Scanning package com.bened
11-23 12:07:54.024: E/PackageManager(68): Package com.bened requires unavailable shared library com.google.android.maps; failing!
11-23 12:07:54.024: W/PackageManager(68): Package couldn't be installed in /data/app/com.bened-1.apk
11-23 12:07:54.184: D/dalvikvm(68): GC_EXPLICIT freed 250K, 49% free 4229K/8263K, external 3511K/4385K, paused 138ms
11-23 12:07:54.296: D/AndroidRuntime(376): Shutting down VM
11-23 12:07:54.325: I/AndroidRuntime(376): NOTE: attach of thread 'Binder Thread #3' failed
11-23 12:07:54.334: D/dalvikvm(376): GC_CONCURRENT freed 213K, 71% free 302K/1024K, external 0K/0K, paused 2ms+4ms
11-23 12:07:54.334: D/jdwp(376): Got wake-up signal, bailing out of select
11-23 12:07:54.334: D/dalvikvm(376): Debugger has detached; object registry had 1 entries
答案 0 :(得分:0)
答案 1 :(得分:0)
请检查您是否使用过2.2的Google API(Google Inc.)Sdk模拟器或任何升级版本。