Ver Mensaje Individual
  #1  
Viejo 18/07/12, 23:35:24
Array

[xs_avatar]
gohan0189 gohan0189 no está en línea
Miembro del foro
 
Fecha de registro: feb 2012
Mensajes: 190
Tu operador: TELCEL

ayudaa geolocalizacon muuy lenta!!

Hola mi problema es que en mi app utilizo la geolocalizacion pero esta tarda demasiado , es por lo que utilizo o asi es??

asi esta mi codigo:

Código:
mport android.app.AlertDialog;
import java.io.IOException;
import java.util.List;
import java.util.Locale;

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

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

/**
 *
 * @author Inmobart
 */
public class GoogleMaps extends MapActivity implements LocationListener
{
    private static final String namespace = "http://tempuri.org/";
     private static String url="http://xxxxxxxx";                    
     private static final String Metodo = "Reportar";
     private static final String accionSoap ="http://tempuri.org/Reportar";
    private MapView mapView;
    private TextView coordenadas;    
    private LocationManager locationManager;
    private MapController controlMapa = null;
    //private Mylocation itemizedoverlay;
    private Geocoder geoCoder;
    EditText edtxtpoliza,edtxtinciso,edtxtplacassiniestro;
    CheckBox checkdañopersona,checkdañoauto;    
    String latitud,longitud;
    
    class MyOverlay extends Overlay {
     GeoPoint point;
    
     public MyOverlay(GeoPoint point) {
     super();
     this.point = point;
     }
    
        @Override
        public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
            super.draw(canvas, mapView, shadow);
 
            Point scrnPoint = new Point();
            mapView.getProjection().toPixels(this.point, scrnPoint);
 
            Bitmap marker = BitmapFactory.decodeResource(getResources(), R.drawable.marcador_google_maps);
            canvas.drawBitmap(marker,
             scrnPoint.x - marker.getWidth() / 2,
             scrnPoint.y - marker.getHeight() / 2, null);
            return true;
        }
    }
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.gps);
        
        mapView=(MapView) findViewById(R.id.map_view);
        coordenadas=(TextView) findViewById(R.id.tw_mensaje);
        edtxt1=(EditText)findViewById(R.id.edtxt1);
       edtxt2=(EditText)findViewById(R.id.edtxt2);      
       checkdañopersona=(CheckBox) findViewById(R.id.chdañopersona);
       checkdañoauto=(CheckBox) findViewById(R.id.chdañoauto);                  
       edtxt3=(EditText)findViewById(R.id.edtxt3); 
        mapView.setBuiltInZoomControls(true);
                
        
       locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);                     
       locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 6000, 50, this);                 
                                      
    }

@Override
protected boolean isRouteDisplayed() {
return false;
}

@Override
public void onLocationChanged(Location location) {
 if(location!=null)
updateLocation(location);
}

@Override
public void onProviderDisabled(String provider) {
   
Intent intent = new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
 
}

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

@Override
public void onProviderEnabled(String provider) {}

protected void updateLocation(Location location){
        mapView = (MapView) findViewById(R.id.map_view);
        controlMapa = mapView.getController();                
        GeoPoint point = new GeoPoint((int) (location.getLatitude() * 1E6), (int) (location.getLongitude() * 1E6));
        Double lat=(Double) (location.getLatitude());
        Double lng=(Double) (location.getLongitude());
        latitud=String.valueOf(lat);
        longitud=String.valueOf(lng); 
        controlMapa.animateTo(point);
        controlMapa.setZoom(30);
        coordenadas.setText("Latitud:"+location.getLatitude()+"\nLongitud:"+location.getLongitude());                 
        geoCoder = new Geocoder(this, Locale.getDefault());
              
        try {
            List<Address> addresses = geoCoder.getFromLocation(
                point.getLatitudeE6() / 1E6,
                point.getLongitudeE6() / 1E6, 1);
        
            String address = "";
            if (addresses.size() > 0) {
                for (int i = 0; i < addresses.get(0).getMaxAddressLineIndex(); i++)
                   address += addresses.get(0).getAddressLine(i) + "\n";
            }
            Toast.makeText(getBaseContext(), address, Toast.LENGTH_SHORT).show();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        
        List<Overlay> mapOverlays = mapView.getOverlays();
        MyOverlay marker = new MyOverlay(point);
        mapOverlays.add(marker);
        mapView.invalidate();
}
o hay una manera para que lo realice mas rapido??

Última edición por gohan0189 Día 18/07/12 a las 23:56:06.
Responder Con Cita