MapActivity заводская ошибка клиента android - PullRequest
1 голос
/ 25 января 2012

Я создал приложение для Android.он был в состоянии выполнить это должным образом, но теперь, когда я выполняю это, говорит Couldn't get connection factory client.я могу видеть карту также, поэтому нет точки неправильного API-ключа.

все работает, но не входит внутрь onLocationChanged(Location location)

EDITED :: код ::

public class GooGleMapsTestDemoActivity extends MapActivity implements LocationListener {
private Logger logger = LogFileWriter.getLogger();
protected MapView mapView;
private MapController controller;
private LocationManager locationManager;
private String latitudeAsString = "";
private String longitudeAsString = "";

private String status = "active";
public static GeoPoint point1;
public static GeoPoint point2;


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    MapView mapView = (MapView) findViewById(R.id.mapView);
    mapView.setBuiltInZoomControls(true);
    controller = mapView.getController();
    mapView.displayZoomControls(true);

    MyLocationOverlay locationOverlay = new MyLocationOverlay(this, mapView);
    locationOverlay.enableMyLocation();
    mapView.getOverlays().add(locationOverlay);
    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_COARSE);
    String provider = locationManager.getBestProvider(criteria, true);
    Log.e("====================>>Provider", provider);
    locationManager.requestLocationUpdates(provider, 0, 0, this);
    Location location = locationManager.getLastKnownLocation(provider);
    TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);




    int longitude = (int) (77.699780 * 1E6);
    int latitude =  (int) (12.951200 * 1E6);
    String text =   "My current location is: " +
    "Latutude = "+latitude+
    "Longitude = "+longitude;
    Toast.makeText(this, text, Toast.LENGTH_LONG).show();

    Log.i("========================>>", text);

    logger.info(text);

    point1 = new GeoPoint(latitude,longitude);
    controller.animateTo(point1);
    controller.setCenter(point1);
    controller.setZoom(14);

}

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

public void onLocationChanged(Location location) {
    Log.e("==============>>location changed", "location changed");
    if (location!=null)
    {
        int longitude = (int)( location.getLongitude() * 1E6);
        int latitude = (int) (location.getLatitude()  * 1E6);
        double lat = location.getLatitude();
        double lng = location.getLongitude();

        if (latitude!=0.0 && longitude!=0.0)
        {
            String text =   "Location changed to: " +
            "Latitude = " + latitude +
            "Longitude = " + longitude;
            Log.i("========================>>", text);
            logger.info(text);
            Toast.makeText(this,text,Toast.LENGTH_LONG).show();
            point2 = point1;
            point1 = new GeoPoint(latitude, longitude);

            controller.animateTo(point2);
            controller.setZoom(14);
            MapOverlay.drawRoute(point1, point2, mapView);
            modifyCoordinates(lat,lng, imeiNo,status);
        }
    }
}

public void onProviderDisabled(String provider)
{
    Toast.makeText(getApplicationContext(), provider+" Disabled", Toast.LENGTH_LONG).show();
    Log.e("========================>>", provider+" Disabled");

    logger.error(provider+" Disabled");
}
public void onProviderEnabled(String provider) 
{
    Toast.makeText(getApplicationContext(), provider+" Enabled", Toast.LENGTH_LONG).show();
    Log.i("========================>>", provider+" Enabled");
    logger.info(provider+" Enabled");
}
public void onStatusChanged(String provider, int status, Bundle extras)
{
    if(status == LocationProvider.OUT_OF_SERVICE)
    {
        logger.info(provider+" is out of service");
    }
    else if(status == LocationProvider.TEMPORARILY_UNAVAILABLE)
    {
        logger.info(provider+" is currently unavailable");
    }
    else if(status == LocationProvider.AVAILABLE) 
    {
        logger.info(provider+" is available");
    }
}

}

Ошибка Logcat ::

E/ZoomButtonsController(586): Cannot make the zoom controller visible if the owner view is not attached to a window.    

E/MapActivity(586): Couldn't get connection factory client

пожалуйста, помогите!Thankx.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...