1

我正在使用HTC Explorer测试我的应用程序

一切都很好,直到我更改代码以显示我当前的位置。该应用程序有效,但在 Logcat 上登录以下错误:无法获取连接工厂客户端

这是我的 MainActivity.java 代码

package com.example.com.draft1;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import android.view.KeyEvent;
import android.widget.Toast;

import com.google.android.maps.MapController;

import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;




public class MainActivity extends MapActivity {




private LocationManager lm;
public LocationListener locationListener;

 // locationListener location =new MyLocationListener();

MapView mapView;
MapController mc;

GeoPoint p;



String coordinates[] = {"41.146064", "-80.642861"};
double lat=Double.parseDouble(coordinates[0]);
double lng=Double.parseDouble(coordinates[1]);

@Override
public void onCreate(Bundle savedInstanceState) {


    lm=(LocationManager)getSystemService(Context.LOCATION_SERVICE);

    locationListener =new MyLocationListener();

    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,locationListener);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    p=new GeoPoint((int)(lat*1E6),(int)(lng*1E6));
    mapView=(MapView)findViewById(R.id.mapView);


    mc=mapView.getController();
    mc.setCenter(p);

    //mc.setZoom(13);
    //mapView.invalidate();


    //myMapController.setCenter(new GeoPoint((int)(lat*1E6),(int)(lng*1E6)));
}

private class MyLocationListener implements LocationListener 
{

@Override
public void onLocationChanged(Location loc) {




    p=new GeoPoint((int)(loc.getLatitude()*1E6),(int)(loc.getLongitude()*1E6));

    if(loc!= null) {
        Toast.makeText(getBaseContext(),"Location : lat"+loc.getLatitude()+" Long "+loc.getLongitude(),Toast.LENGTH_SHORT).show();

    }

    mc.animateTo(p);

    }

    @Override
    public void onProviderDisabled(String provider) {

    }

    @Override 
    public void onProviderEnabled(String provider) {

    }

    @Override 
    public void onStatusChanged(String provider,int status,Bundle extras) {

    }
}




@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}
@Override
protected boolean isRouteDisplayed() 

{
    //adssad

    return false;

}



} 

为什么会发生这种情况?

任何可能的解决方案?

我真的很感激这方面的帮助

干杯!

4

1 回答 1

0

似乎是谷歌的随机错误。开始自己工作:|

于 2012-09-25T02:58:43.047 回答