메인은 이렇구요
package org.androidtown.mylocationmap;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
public class MyLocationMapActivity extends MapActivity {
TextView text01;
MapView mapview;
public static void main(String[] args){}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text01 = (TextView) findViewById(R.id.text01);
mapview = (MapView) findViewById(R.id.mapview);
mapview.setBuiltInZoomControls(true);
Button button01=(Button) findViewById(R.id.button01);
button01.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
getMyLocation1();
}
});
}
private void getMyLocation1(){
LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
long minTime = 10000;
float minDistance = 0;
MyLocationListener listener = new MyLocationListener();
manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, minTime, minDistance, listener);
appendText("내 위치를 요청했습니다.");
}
private void appendText(String msg){
text01.append(msg+"\n");
}
class MyLocationListener implements LocationListener{
public void onLocationChanged(Location location) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();
appendText("현재위치 :"+latitude +","+longitude);
showMyLocation(latitude, longitude);
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
}
private void showMyLocation(double latitude,double longitude){
int intLatitude = new Double (latitude*1000000).intValue();
int intlongitude = new Double (longitude*1000000).intValue();
GeoPoint myPoint = new GeoPoint(intLatitude, intlongitude);
MapController controller = mapview.getController();
controller.animateTo(myPoint);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
매니퍼스트 부분입니다.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.androidtown.mylocationmap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MyLocationMapActivity"
android:label="@string/app_name" >
<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>
xml은 이렇구요
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_margin="10dp"
android:text="내위치확인"
android:textSize="16dp"
android:textStyle="bold"/>
<com.google.android.maps.Mapview
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/text01"
android:layout_below="@+id/button01"
android:clickable="true"
android:apiKey="0R0ngXsqGoYh3WvQtZQudhpjEn_n2fPppsvvHXw"
/>
<TextView
android:id="@+id/text01"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:layout_alignParentBottom="true"
android:background="#ffffffff"
android:text=""
android:textSize="16dp"
android:textStyle="bold"
android:textColor="#ff000000"/>
</RelativeLayout>
이렇게 작성하였는데요 에뮬레이터 실행하니 실행은안되고 이런에러들이 뜨네요 제발 부탁드립니다..ㅜㅜ
05-20 19:07:38.712: E/AndroidRuntime(827): FATAL EXCEPTION: main
05-20 19:07:38.712: E/AndroidRuntime(827): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.androidtown.mylocationmap/org.androidtown.mylocationmap.MyLocationMapActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class com.google.android.maps.Mapview
05-20 19:07:38.712: E/AndroidRuntime(827): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.os.Handler.dispatchMessage(Handler.java:99)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.os.Looper.loop(Looper.java:137)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-20 19:07:38.712: E/AndroidRuntime(827): at java.lang.reflect.Method.invokeNative(Native Method)
05-20 19:07:38.712: E/AndroidRuntime(827): at java.lang.reflect.Method.invoke(Method.java:511)
05-20 19:07:38.712: E/AndroidRuntime(827): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-20 19:07:38.712: E/AndroidRuntime(827): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-20 19:07:38.712: E/AndroidRuntime(827): at dalvik.system.NativeStart.main(Native Method)
05-20 19:07:38.712: E/AndroidRuntime(827): Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class com.google.android.maps.Mapview
05-20 19:07:38.712: E/AndroidRuntime(827): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-20 19:07:38.712: E/AndroidRuntime(827): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.app.Activity.setContentView(Activity.java:1835)
05-20 19:07:38.712: E/AndroidRuntime(827): at org.androidtown.mylocationmap.MyLocationMapActivity.onCreate(MyLocationMapActivity.java:26)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.app.Activity.performCreate(Activity.java:4465)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-20 19:07:38.712: E/AndroidRuntime(827): ... 11 more
05-20 19:07:38.712: E/AndroidRuntime(827): Caused by: java.lang.ClassNotFoundException: com.google.android.maps.Mapview
05-20 19:07:38.712: E/AndroidRuntime(827): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-20 19:07:38.712: E/AndroidRuntime(827): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-20 19:07:38.712: E/AndroidRuntime(827): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
05-20 19:07:38.712: E/AndroidRuntime(827): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
05-20 19:07:38.712: E/AndroidRuntime(827): ... 21 more
Caused by: java.lang.ClassNotFoundException: com.google.android.maps.Mapview 보니 에뮬을 googlemap관련 에뮬로 띠우셧나요 에뮬도 맵띠우는게 가능한게잇고 없는게 잇을텐데요