Home Menu

Menu



Programación y Desarrollo para Android Subforo exclusivo para temas de programación de software para PDAs y desarrollo de aplicaciones, interfaces, etc bajo Android


 
Herramientas
  #1  
Viejo 19/03/13, 15:01:17
Avatar de pernath
pernath pernath no está en línea
Miembro del foro
Mensajes: 83
Compra y venta: (1)
 
Fecha de registro: may 2011
Mensajes: 83
Modelo de smartphone: LG optimus 2x
Tu operador: Movistar
Mencionado: 0 comentarios
Tagged: 0 hilos
Ayuda, please

Buenas a todos,

a ver si alguien me puede echar un cable

tengo este activity en el que recupero unos puntos gps y los muestro en un mapview.
El problema es que parece que cuando creo el overlayItem y pongo los bmp genera un bucle infinito hasta que al cabo de unos 15 segudnos el activity da un forzar cierre. No lo veo

El código es el siguiente:


public class puntos_mapa extends MapActivity{

ProgressDialog pd = null;
private MapView mapa_p = null;
private MapController controlMapa = null;
private coordenadasbd db_load;
private String desc;
private int buffer21;
private int buffer22;
private int contador = 0;
private LocationManager locManager;

@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub


return false;
}



@Override
protected void onCreate(Bundle icicle) {
// TODO Auto-generated method stub
super.onCreate(icicle);


requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.puntos_mapa);

//Obtenemos una referencia al control MapView
mapa_p = (MapView)findViewById(R.id.mapa_xml);
//Mostramos los controles de zoom sobre el mapa
mapa_p.setBuiltInZoomControls(true);

controlMapa = mapa_p.getController();
controlMapa.setZoom(10);

//db_load=new coordenadasbd(this);

contador= contador + 1;

marcar_pos();


}


public double Redondear(double nD, int nDec)
{
return Math.round(nD*Math.pow(10,nDec))/Math.pow(10,nDec);
}







public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
//finish();

startActivity(new Intent(getApplication(), AndLocationActivity.class));

return true;
}
return super.onKeyDown(keyCode, event);
}



private void marcar_pos (){
/*Dibujar layer encima*

mapa_p.invalidate();
List<Overlay> capas = mapa_p.getOverlays();
OverlayMapa om = new OverlayMapa(null, mapa_p);
capas.add(om);
mapa_p.postInvalidate();

//capas.clear();

}


public class OverlayMapa extends Overlay {
public OverlayMapa(Context context, MapView mapView) {
super();


}


@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow)
{

db_load=new coordenadasbd(puntos_mapa.this);
try {
db_load.abrir();
Cursor c=db_load.ObtenerCoordenadas();
startManagingCursor(c);

contador=contador + 1;


if (c.moveToFirst())
{
do{

float buffer2 = ((float)c.getFloat(2));
float buffer3 = ((float)c.getFloat(3));
desc = c.getString(1);

buffer21=(int) (buffer2 * 1E6);
buffer22=(int) (buffer3 * 1E6);

Projection projection = mapView.getProjection();


GeoPoint geoPoint =
new GeoPoint(buffer21, buffer22);


if (shadow == false)
{

Point centro = new Point();
projection.toPixels(geoPoint, centro);

//Definimos el pincel de dibujo
Paint p = new Paint();
p.setColor(Color.BLACK);

Point screenPts = mapView.getProjection().toPixels(geoPoint, null);
//create a rotated copy of the marker
Bitmap arrowBitmap = BitmapFactory.decodeResource( mapa_p.getResources(), R.drawable.blue_pin_2);
Matrix matrix = new Matrix();
//matrix.postRotate(this.getOrientation());
mapView.postInvalidate();
Bitmap rotatedBmp = Bitmap.createBitmap(
arrowBitmap,
0, 0,
arrowBitmap.getWidth(),
arrowBitmap.getHeight(),
matrix,
true
);
// add the rotated marker to the canvas


canvas.drawBitmap(
rotatedBmp,
screenPts.x - (rotatedBmp.getWidth() / 2),
screenPts.y - (rotatedBmp.getHeight() / 2),
null
);

canvas.drawText(desc, centro.x+25, centro.y+5, p);

}


}while (c.moveToNext());

}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();

}



db_load.cerrar();

}




}

}


#############################
ERROR:
03-19 14:03:36.306: E/AndroidRuntime(290): Uncaught handler: thread main exiting due to uncaught exception
03-19 14:03:36.336: E/AndroidRuntime(290): java.lang.IllegalStateException: Couldn't init cursor window
03-19 14:03:36.336: E/AndroidRuntime(290): at android.database.CursorWindow.native_init(Native Method)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.database.CursorWindow.<init>(CursorWindow. java:41)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.database.sqlite.SQLiteCursor.fillWindow(SQ LiteCursor.java:277)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.database.sqlite.SQLiteCursor.getCount(SQLi teCursor.java:269)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.database.AbstractCursor.moveToPosition(Abs tractCursor.java:171)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.database.AbstractCursor.moveToFirst(Abstra ctCursor.java:248)
03-19 14:03:36.336: E/AndroidRuntime(290): at com.AndLocation.AndLocation.puntos_mapa$OverlayMap a.draw(puntos_mapa.java:156)
03-19 14:03:36.336: E/AndroidRuntime(290): at com.google.android.maps.Overlay.draw(Overlay.java: 179)
03-19 14:03:36.336: E/AndroidRuntime(290): at com.google.android.maps.OverlayBundle.draw(Overlay Bundle.java:45)
03-19 14:03:36.336: E/AndroidRuntime(290): at com.google.android.maps.MapView.onDraw(MapView.jav a:476)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.view.View.draw(View.java:6535)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.view.ViewGroup.drawChild(ViewGroup.java:15 31)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.view.ViewGroup.dispatchDraw(ViewGroup.java :1258)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.view.ViewGroup.drawChild(ViewGroup.java:15 29)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.view.ViewGroup.dispatchDraw(ViewGroup.java :1258)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.view.View.draw(View.java:6538)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.widget.FrameLayout.draw(FrameLayout.java:3 52)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.view.ViewGroup.drawChild(ViewGroup.java:15 31)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.view.ViewGroup.dispatchDraw(ViewGroup.java :1258)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.view.View.draw(View.java:6538)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.widget.FrameLayout.draw(FrameLayout.java:3 52)
03-19 14:03:36.336: E/AndroidRuntime(290): at com.android.internal.policy.impl.PhoneWindow$Decor View.draw(PhoneWindow.java:1830)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.view.ViewRoot.draw(ViewRoot.java:1349)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.view.ViewRoot.performTraversals(ViewRoot.j ava:1114)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.view.ViewRoot.handleMessage(ViewRoot.java: 1633)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.os.Handler.dispatchMessage(Handler.java:99 )
03-19 14:03:36.336: E/AndroidRuntime(290): at android.os.Looper.loop(Looper.java:123)
03-19 14:03:36.336: E/AndroidRuntime(290): at android.app.ActivityThread.main(ActivityThread.jav a:4363)
03-19 14:03:36.336: E/AndroidRuntime(290): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 14:03:36.336: E/AndroidRuntime(290): at java.lang.reflect.Method.invoke(Method.java:521)
03-19 14:03:36.336: E/AndroidRuntime(290): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:860)
03-19 14:03:36.336: E/AndroidRuntime(290): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:618)
03-19 14:03:36.336: E/AndroidRuntime(290): at dalvik.system.NativeStart.main(Native Method)
03-19 14:03:36.356: I/dalvikvm(290): threadid=7: reacting to signal 3
03-19 14:03:36.356: E/dalvikvm(290): Unable to open stack trace file '/data/anr/traces.txt': Too many open files
03-19 14:03:40.319: E/OSNetworkSystem(290): unclassified errno 24 (Too many open files)
03-19 14:03:52.256: E/OSNetworkSystem(290): unclassified errno 24 (Too many open files)
03-19 14:04:07.167: E/OSNetworkSystem(290): unclassified errno 24 (Too many open files)
03-19 14:04:25.826: E/OSNetworkSystem(290): unclassified errno 24 (Too many open files)
03-19 14:04:49.166: E/OSNetworkSystem(290): unclassified errno 24 (Too many open files)
03-19 14:05:18.316: E/OSNetworkSystem(290): unclassified errno 24 (Too many open files)
03-19 14:05:54.698: E/OSNetworkSystem(290): unclassified errno 24 (Too many open files)
03-19 14:06:40.210: E/OSNetworkSystem(290): unclassified errno 24 (Too many open files)
03-19 14:07:37.056: E/OSNetworkSystem(290): unclassified errno 24 (Too many open files)
03-19 14:07:51.786: I/Process(290): Sending signal. PID: 290 SIG: 9
03-19 14:07:52.476: E/ActivityThread(306): Failed to find provider info for com.google.settings
03-19 14:07:52.486: E/ActivityThread(306): Failed to find provider info for com.google.settings
03-19 14:07:52.509: E/ActivityThread(306): Failed to find provider info for com.google.settings

Última edición por pernath Día 19/03/13 a las 15:09:38
Responder Con Cita


  #2  
Viejo 22/03/13, 09:49:25
Avatar de pernath
pernath pernath no está en línea
Miembro del foro
Mensajes: 83
Compra y venta: (1)
 
Fecha de registro: may 2011
Mensajes: 83
Modelo de smartphone: LG optimus 2x
Tu operador: Movistar
Mencionado: 0 comentarios
Tagged: 0 hilos
Solucionado.

Hay que utilizar la clase OverlayItem para añadir más de una imagen en un overlay.
Responder Con Cita
Respuesta

Estás aquí
Regresar   HTCMania > Todo sobre Android > Programación y Desarrollo para Android


Reglas de Mensajes
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Las caritas están On
Código [IMG] está On
Código HTML está Off

Saltar a Foro



Hora actual: 03:05:48 (GMT +1)

Cookies
Powered by vBulletin™
Copyright © vBulletin Solutions, Inc. All rights reserved.
 
HTCMania: líderes desde el 2007