百度地图报错问题,求救

-Mop- 发布于 2013/04/27 21:01
阅读 1K+
收藏 0

请问一下这是什么问题,谢谢

package com.example.gpstest;

import com.baidu.mapapi.BMapManager;
import com.baidu.mapapi.LocationListener;
import com.baidu.mapapi.MKLocationManager;
import com.baidu.mapapi.MapActivity;

import android.location.Location;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends MapActivity {
	
	private BMapManager mapManager;
	private MKLocationManager mLocationManager = null;
	
	TextView t1;
	TextView t2;
	Button b;
	Location location;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mapManager = new BMapManager(getApplication());
		mapManager.init("937F85AE5C083238578F13AFEF100E9201839AA2", null);
		
		setContentView(R.layout.activity_main);
		
		t1 = (TextView)findViewById(R.id.textView1);
		t2 = (TextView)findViewById(R.id.textView2);
		b = (Button)findViewById(R.id.button1);

		super.initMapActivity(mapManager);
		  
		mLocationManager = mapManager.getLocationManager();
			// 注册位置更新事件
		mLocationManager.requestLocationUpdates((LocationListener) this);
			// 使用GPS定位
		mLocationManager.enableProvider((int) MKLocationManager.MK_GPS_PROVIDER);
		
		
		b.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				t1.setText("当前经度:" + location.getLongitude());
				t2.setText("当前纬度:" + location.getLatitude());
			}});

	}
	
	public void onLocationChanged(Location location) {
		if (location != null) {
			// 显示定位结果
			location.getLongitude();
			location.getLatitude();
		}
	}

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}

}
加载中
0
Ryan-瑞恩
Ryan-瑞恩
在Manfies文件中声明了这个Activity了吗?
返回顶部
顶部