마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

구글맵을 액티비티로 호출하면 되는데, 인텐트로 호출하면 오류가 납니다.

0 추천
package com.example.taxita;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class LogIn extends Activity{
	protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    	/**로그인 화면 띄우기 - 로그인을 클래스로 분류해야하나? */
        setContentView(R.layout.activity_login);
        final Context thisActivity = (Context)this; //현재의 액티비티의 객체 정의
        Button button_login= (Button)findViewById(R.id.button1); //로그인 버튼 객체 생성
        Button button_signup= (Button)findViewById(R.id.button2); //가입 버튼 객체 생성
        OnClickListener button_signupClickListener = new OnClickListener()
        {//클릭 리스너 - 등록하기의  레이아웃을 부른다. 내용이 많은데, 분리해야하나?
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				//setContentView(R.layout.activity_signup);
				//구글맵이 아닌 클래스를 불러오는건 잘됩니다.
				Intent intent_signup = new Intent(thisActivity, SignUp.class);
				startActivity(intent_signup);
			}
        	
        };
        button_signup.setOnClickListener(button_signupClickListener); //메소드실행
        
        OnClickListener button_loginClickListener = new OnClickListener()
        {//클릭 리스너
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				//로그인 완료되면 맵 클래스를 부르는데.....앱이 종료됩니다.
				Intent intent_map = new Intent(thisActivity, Map.class);
				startActivity(intent_map);
//클래스를 부르면 안되고 액티비티를 부르면 실행이됩니다.
			}
        	
        };
        button_login.setOnClickListener(button_loginClickListener); //메소드실행 	
	}

}

이게 인텐트를 호출하는 LogIn 클래스입니다. 

 

 

아래것이 호출된 Map 클래스입니다. 여기서 지금은 액티비티만 불러오는데도 실행이 되지 않습니다.

package com.example.taxita;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;


import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.KeyEvent;
import android.view.Menu;

public class Map extends FragmentActivity{
	
	private GoogleMap mMap; //컨트롤러 할당할 필요 없음
	static final LatLng GWANG = new LatLng(37.57227, 126.97747);
	
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_map);
		
		
		//MapFragment mMapFragment = MapFragment.newInstance();
		//FragmentTransaction fragmentTransaction =
		 //       getFragmentManager().beginTransaction();
		//fragmentTransaction.add(R.id., mMapFragment);
		//fragmentTransaction.commit();
		
		//GeoPoint point = new GeoPoint(36597889,128056641);
		//init();	
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.layout.activity_map, menu);
		
		return true;
	}
	
	void init(){

		mMap = ((SupportMapFragment)getSupportFragmentManager().
				findFragmentById(R.id.map)).getMap();
		addMarker();	
	}
	
	void addMarker(){
		 mMap.addMarker(new MarkerOptions().
				position(new LatLng(37.57227, 126.97747)).title("광화문"));
	}
}

 

 

 

아래것이 Map클래스의 액티비티입니다.

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
  android:id="@+id/map"
  android:name="com.google.android.gms.maps.MapFragment"
  android:layout_width="match_parent"
  android:layout_height="match_parent" 
  
  
  map:cameraTargetLat="37.57227"
  map:cameraTargetLng="126.97747"
  map:cameraZoom="16"
  map:mapType="normal"
  map:uiRotateGestures="true"
  map:uiTiltGestures="true"
  map:uiZoomGestures="true"
  />

  

 

 

아래가 에러나서 종료될때의 로그캣입니다.

 

 

 

이것때문에 도대체 며칠동안 삽질중인지 모르겠네요ㅠㅠ

제발 고치고싶습니다 도와주세여ㅠㅠㅠㅠ

안드로이드3주 (120 포인트) 님이 2013년 5월 26일 질문
혹, 해결되셨는지요? 저도 같은 에러로 고생중이네요.

1개의 답변

0 추천
map class 40번째줄 이상하네요...
SGLEE (1,690 포인트) 님이 2013년 5월 26일 답변
...