关于android的MapView有关问题,求教大神解救
关于android的MapView问题,求教大神解救
想使用google map api,但使用的时候总是被强制关闭。不知道为什么,android新手。
PS:apiKey 、权限什么的都是按照例子一步一步做的。
下面是main.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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="0qHIu1zAnyTA1-dCOPJKideYeMucl5oQXFvILLw"
android:clickable="true"
android:enabled="true"
/>
</LinearLayout>
AndroidManifest.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.guan"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".GoogleMapTestActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps"/>
</application>
</manifest>
源代码:
package android.guan;
import com.google.android.maps.MapActivity;
import android.os.Bundle;
import com.google.android.maps.*;
public class GoogleMapTestActivity extends MapActivity {
private MapView mapview;
private MapController controller;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// mapview=(MapView)findViewById(R.id.map);
// controller =mapview.getController();
// mapview.setSatellite(true);
// mapview.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
Logcat信息:
03-09 15:52:30.514: E/ActivityThread(598): Failed to find provider info for com.google.settings
03-09 15:52:30.534: E/ActivityThread(598): Failed to find provider info for com.google.settings
03-09 15:52:30.564: E/ActivityThread(598): Failed to find provider info for com.google.settings
03-09 15:52:30.654: D/AndroidRuntime(598): Shutting down VM
03-09 15:52:30.654: W/dalvikvm(598): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
想使用google map api,但使用的时候总是被强制关闭。不知道为什么,android新手。
PS:apiKey 、权限什么的都是按照例子一步一步做的。
下面是main.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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="0qHIu1zAnyTA1-dCOPJKideYeMucl5oQXFvILLw"
android:clickable="true"
android:enabled="true"
/>
</LinearLayout>
AndroidManifest.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.guan"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".GoogleMapTestActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps"/>
</application>
</manifest>
源代码:
package android.guan;
import com.google.android.maps.MapActivity;
import android.os.Bundle;
import com.google.android.maps.*;
public class GoogleMapTestActivity extends MapActivity {
private MapView mapview;
private MapController controller;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// mapview=(MapView)findViewById(R.id.map);
// controller =mapview.getController();
// mapview.setSatellite(true);
// mapview.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
Logcat信息:
03-09 15:52:30.514: E/ActivityThread(598): Failed to find provider info for com.google.settings
03-09 15:52:30.534: E/ActivityThread(598): Failed to find provider info for com.google.settings
03-09 15:52:30.564: E/ActivityThread(598): Failed to find provider info for com.google.settings
03-09 15:52:30.654: D/AndroidRuntime(598): Shutting down VM
03-09 15:52:30.654: W/dalvikvm(598): threadid=3: thread exiting with uncaught exception (group=0x4001b188)