나는 모든 문제를 해결할 때마다 오류를 찾기 위해 모든 코드와 모든 질문을 시도했습니다. 그 밖의 것이 무언가를 무너 뜨리고 그리드의 사각형 상자가 모든지도를 덮으면 모든 것이 필요합니다. 지도를 클릭하는 동안 마크를 그리고 GPS를 사용하여 텍스트 뷰에 주소를 얻을이 출력은 this처럼 보인다 그리고 난 에뮬레이터 내 인터넷 연결을 테스트하며Google지도가 제대로 표시되지 않고 닫히기가 어렵습니다.
여기입니다 로그 캣 오류 작동합니다
01-23 03:37:52.868: E/MapActivity(309): Couldn't get connection factory client
01-23 03:37:53.979: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-23 03:37:53.979: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-23 03:37:53.989: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
01-23 03:37:53.989: E/QemuSensors(309): data__poll: len=-1, errno=9: Bad file number
여기를 코드 :
public class Map extends MapActivity implements LocationListener {
MapView map = null;
long start;
long end;
MyLocationOverlay compass = null;
MapController c;
int x, y;
GeoPoint g;
Drawable d;
LocationManager n;
int lati = 0;
int longi = 0;
Customize cus;
Drawable drawable;
OverlayItem f;
Location location;
String add = "";
Criteria m;
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.map);
map = (MapView) findViewById(R.id.mapid);
map.getController();
map.setBuiltInZoomControls(true);
map.setStreetView(true);
map.getController().setZoom(19);
// map.setTraffic(true);
d = getResources().getDrawable(R.drawable.blue);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
drawable = this.getResources().getDrawable(R.drawable.red);
drawable.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
map.getOverlays().add(new Customize(d));
compass = new MyLocationOverlay(Map.this, map);
map.getOverlays().add(compass);
getLastLocation();
}
public void getLastLocation() {
String provider = getBestProvider();
location = n.getLastKnownLocation(provider);
if (location != null) {
setCurrentLocation(location);
} else {
Toast.makeText(this, "Location not yet acquired", Toast.LENGTH_LONG)
.show();
}
((TextView) findViewById(R.id.providerid)).setText("Provider :"
+ getBestProvider());
}
public String getBestProvider() {
n = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
m = new Criteria();
m.setPowerRequirement(Criteria.NO_REQUIREMENT);
m.setAccuracy(Criteria.NO_REQUIREMENT);
String bestProvider = n.getBestProvider(m, false);
return bestProvider;
}
@Override
protected void onPause() {
compass.disableCompass();
super.onPause();
n.removeUpdates(this);
}
@Override
protected void onResume() {
compass.enableCompass();
super.onResume();
n.requestLocationUpdates(getBestProvider(), 500, 1, this);
}
class maps extends Overlay {
@Override
public boolean onTouchEvent(MotionEvent event, MapView mapView) {
// ---when user lifts his finger---
if (event.getAction() == 1) {
g = mapView.getProjection().fromPixels((int) event.getX(),
(int) event.getY());
Geocoder geoCoder = new Geocoder(getBaseContext(),
Locale.getDefault());
try {
List<Address> addresses = geoCoder.getFromLocation(
g.getLatitudeE6()/1E6, g.getLongitudeE6()/1E6,
1);
if (addresses.size() > 0) {
for (int i = 0; i < addresses.get(0)
.getMaxAddressLineIndex(); i++)
add += addresses.get(0).getAddressLine(i) + "\n";
((TextView) findViewById(R.id.address)).setText(add);
}
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
return false;
}
/*
* public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
* long when) {
*
* try{ super.draw(canvas, mapView, shadow); //---translate the GeoPoint
* to screen pixels--- g= new GeoPoint((int) (lati * 1E6), (int) (longi
* * 1E6)); Point screenPts = new Point();
* mapView.getProjection().toPixels(g, screenPts); //---add the
* marker--- Bitmap bmp = BitmapFactory.decodeResource(getResources(),
* R.drawable.blue); canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50,
* null); } catch(Exception h){
*
* h.printStackTrace(); } finally{
*
* map.setSatellite(!map.isSatellite());
*
* }
*
*
* return true; }
*/
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
public void setCurrentLocation(Location location) {
lati = (int) (location.getLatitude() * 1E6);
longi = (int) (location.getLongitude() * 1E6);
g = new GeoPoint(lati, longi);
map.getOverlays().add(new Customize(drawable));
}
@Override
public void onLocationChanged(Location arg0) {
setCurrentLocation(arg0);
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
Toast.makeText(this, "Provider Disabled", Toast.LENGTH_SHORT).show();
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
Toast.makeText(this, "Provider Enabled", Toast.LENGTH_SHORT).show();
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
Toast.makeText(this, "Staus Changed", Toast.LENGTH_SHORT).show();
}
private GeoPoint getPoint(double lat, double lon) {
return (new GeoPoint((int) (lat * 1000000.0), (int) (lon * 1000000.0)));
}
public class Customize extends ItemizedOverlay<OverlayItem> {
ArrayList<OverlayItem> ar = new ArrayList<OverlayItem>();
private Drawable defaultMarker = null;
public Customize(Drawable defaultMarker) {
super(defaultMarker);
this.defaultMarker = defaultMarker;
boundCenterBottom(defaultMarker);
ar.add(new OverlayItem(getPoint(40.748963847316034,
-73.96807193756104), "UN", "United Nations"));
ar.add(new OverlayItem(getPoint(40.76866299974387,
-73.98268461227417), "Lincoln Center",
"Home of Jazz at Lincoln Center"));
ar.add(new OverlayItem(getPoint(40.765136435316755,
-73.97989511489868), "Carnegie Hall",
"Where you go with practice, practice, practice"));
ar.add(new OverlayItem(getPoint(40.70686417491799,
-74.01572942733765), "The Downtown Club",
"Original home of the Heisman Trophy"));
ar.add(new OverlayItem(getPoint(lati, longi), " ", " "));
populate();
}
@Override
protected OverlayItem createItem(int i) {
// TODO Auto-generated method stub
return ar.get(i);
}
@Override
public int size() {
// TODO Auto-generated method stub
return ar.size();
}
protected boolean onTap(int i) {
Toast.makeText(Map.this, ar.get(i).getSnippet(), Toast.LENGTH_SHORT)
.show();
return (true);
}
}
}
매니페스트 :
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:label="@string/app_name"
android:name=".ShareActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="@string/app_name"
android:name=".Map" >
<intent-filter >
<action android:name="com.share.MAP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
당신이뿐만 아니라'logcat' 정보를 게시 할 수있어? –
죄송하지만 ican't 가져 오기 내 logcat 여기, 어떤 시체도 내가 이베이 물건을 시도 도와주세요! – Weloo
일부 책에서는 응용 프로그램이 충분히 빠르게 응답하지 않을 때 ('5 초가 걸린다') '강제 종료'가 발생한다고 읽었습니다. 그렇다면 실행 시간이 많이 걸리는 코드를 다른 스레드로 옮기십시오. –