Apps calling an HTML does not run on BB

60 views
Skip to first unread message

rube...@yahoo.com

unread,
Sep 25, 2013, 12:54:35 PM9/25/13
to codenameone...@googlegroups.com
Hi,
Hello, create an apps which submits the latitude and longitude to a HTML file that connects to Google Maps.  The position is shown in the HTML with a circle of diameter of 2.5 km.  This runs perfectly on the emulator but when passing it to my Bold does not display the map. The same happens in a cell phone Torch.

Thanks.

My code in Java:
    private void mostrarMapa(final Dialog progreso) {
        final Form mapa = new Form("Mapa de Localización");
        mapa.setLayout(new BorderLayout());
        mapa.setScrollable(false);
        try {
            Location loc = LocationManager.getLocationManager().getCurrentLocation();
            final Coord lastLocation = new Coord(loc.getLatitude(), loc.getLongtitude());
            WebBrowser web = new WebBrowser(){
                @Override     
                public void onLoad(String url) {                         
                    Component c = getInternal();                        
                    if(c instanceof BrowserComponent) {                                
                        BrowserComponent b = (BrowserComponent)c;  
                        String mensaje = Double.toString(lastLocation.getLatitude()) + "," + Double.toString(lastLocation.getLongitude());
                        b.execute("mapa('" + mensaje + "')");                        
                    }                    
                } }; 
            mapa.addComponent(BorderLayout.CENTER, web); 
            web.setURL("jar:///mapa.html");  
            
        } catch (IOException ex) {
            Dialog.show("Error", ex.getMessage(), "Ok", null);
//            Logger.getLogger(IdentificaPosicion.class.getName()).log(Level.SEVERE, null, ex);
        }
        progreso.dispose();
        mapa.show();      
    }

My code in HTML:
      // Pase de parametros de app a html
        function mapa(mensaje) { 
            var punto = mensaje.split(",");
            rutaMarcas();
            map.setCenter(new google.maps.LatLng(punto[0], punto[1])); 
            adicionMarca('Usted esta aquí',new google.maps.LatLng(punto[0], punto[1]),EJE);
            marcaCirculo(new google.maps.LatLng(punto[0], punto[1]));
//                map.setZoom(zoom);
        } 

      // Pon Marcas dentro de los poligonos que son parte de la ruta
        function rutaMarcas() {      
            // Inicia eliminando las rutas si existen
            eliminaMarcas();
            for  ( var x = 0; x < puntos.length; x++)  {
                var punto = puntos[x].split(",");
                adicionMarca(punto[0],new google.maps.LatLng(punto[1], punto[2]),PTO)                     
            }       
        }
        // Adiciona una marca al mapa y empujalo al arreglo.
        function adicionMarca(nombre,localizacion,tipo) {
            if (tipo == PTO){
                var marca = new google.maps.Marker({
                    position: localizacion,
                    title: nombre,
                    map: map
                });
            } else {
                 var marca = new google.maps.Marker({
                    position: localizacion,
                    title: nombre,
                    map: map
                });               
            }
            marcas.push(marca);
        }
        // Elimina todas las marcas en el arreglo y remueve las referencias a el
        function eliminaMarcas() {
            if (marcas) {
                for (i in marcas) {
                    marcas[i].setMap(null);
                }
                marcas.length = 0;
            }
        } 
        // Funcion que permite Dibujar un circulo al rededor del punto donde se encuentre el usuario
        function marcaCirculo(latLng) {
            var circulo = {
              strokeColor: "red", //  "#008888",  // Color del borde del círculo
              strokeOpacity: 0.6, // opacidad dl borde (entre 9,9 y 1) 
              strokeWeight: 2,  // ancho del borde en px
              fillColor:  "yellow", // "#880088",  // Color del relleno
              fillOpacity: 0.4,  // Opacidad del relleno
              geodesic: true,  // gedodésica sobre la Tierra (por defecto es false)
              map: map,  // El mapa con el que estamos trabajando
              center: latLng,  // En este caso el mismo que nuestro marcador
              radius: 2574.95  // Radio del círculo (correspondiente a metros) La conversion se base en la siguiente fórmula: 1 metro equivale a 0.000621371192 millas (1 m. = 0.000621371192 milla)
            };   
            cityCircle = new google.maps.Circle(circulo);
        }

Shai Almog

unread,
Sep 25, 2013, 11:26:59 PM9/25/13
to codenameone...@googlegroups.com, rube...@yahoo.com
Hi,
we disabled the webkit browser on RIM devices by default since it is so flaky. The HTML works with the basic J2ME renderer on those devices.
You can turn it on explicitly by adding the build argument rim.nativeBrowser=true

rube...@yahoo.com

unread,
Sep 26, 2013, 9:22:31 AM9/26/13
to codenameone...@googlegroups.com, rube...@yahoo.com
Hi,

Register parameter rim.nativeBrowser=true, However the server shows me an error message with a file attached.
I can not understand what is the problem, I appreciate any help.

Best regards

error (1).txt

Shai Almog

unread,
Sep 26, 2013, 10:38:55 AM9/26/13
to codenameone...@googlegroups.com, rube...@yahoo.com
Its a failure of the RIM signing server. These things happen when developing for RIM, just send another build after waiting a bit.

rube...@yahoo.com

unread,
Sep 26, 2013, 4:35:40 PM9/26/13
to codenameone...@googlegroups.com, rube...@yahoo.com
Hi,
 
I went back to send to the server the file, but to run with the same results in BB. 

I generate a version on Android but having active GPS shows me the message "cannot retrieve location try later".  If turn off the GPS shows me google map and mark my position based on triangulation.

rube...@yahoo.com

unread,
Sep 26, 2013, 4:48:34 PM9/26/13
to codenameone...@googlegroups.com, rube...@yahoo.com
As for the BB I am struck that the server generates more than one file to download as shown in the attached picture.


serverImage.png

Shai Almog

unread,
Sep 26, 2013, 10:36:07 PM9/26/13
to codenameone...@googlegroups.com, rube...@yahoo.com
In Android you need to use the listener which will be invoked based on GPS signal. Keep in mind that you need to debug it where GPS signal is reachable.

You get 2 builds on RIM 42 = devices running OS 4.2 (no touch support, no native browser).
RIM 5 = devices running OS 5 and newer. Touch, native browser option etc.

rube...@yahoo.com

unread,
Sep 27, 2013, 7:37:48 AM9/27/13
to codenameone...@googlegroups.com, rube...@yahoo.com
Then I have to have 2 versions of the application.  Is this correct?

Shai Almog

unread,
Sep 27, 2013, 10:57:15 AM9/27/13
to codenameone...@googlegroups.com, rube...@yahoo.com
Only if you want to support devices older than 5.0 which are already pretty rare. You can send a build with rim.ignoreLegacy (if I remember correctly) set to true in the build hints which should only produce one version and a faster build.
Reply all
Reply to author
Forward
0 new messages