Organizational Research By

Surprising Reserch Topic

titanium httpclient the persistent handle is disposed using -'titanium-mobile,titanium-alloy,titanium-android'


titanium httpclient the persistent handle is disposed  using -'titanium-mobile,titanium-alloy,titanium-android'

I'm trying to download a big JSON form a WS. In iOS all work fine, but in Android the app crashes.

1.- Looking for a solution I found that it can be caused by the sqlite and I removed the collection.save(); to avoid this problem. With this fix, this message doesn't appear anymore:


  Choreographer: Skipped 30 frames! The application may be doing too
  much work on its main thread.


2.- Now, the only strange message that I can see in the console is:


  HTTPClient: The persistent handle is disposed.


The console actually shows:


  [DEBUG] :  Module: Loading module: alloy/controllers/disponibleRow ->
  Resources/alloy/controllers/disponibleRow.js
  
  [DEBUG] :  Module:
  Loading module: alloy/controllers/usadoRow ->
  Resources/alloy/controllers/usadoRow.js
  
  [DEBUG] :  dalvikvm:
  GC_CONCURRENT freed 2648K, 22% free 13644K/17456K, paused 4ms+22ms,
  total 88ms [DEBUG] :  AbsListView: Get MotionRecognitionManager
  
  [DEBUG] :  dalvikvm: GC_CONCURRENT freed 2371K, 24% free
  13320K/17456K, paused 3ms+3ms, total 56ms
  
  [DEBUG] :  dalvikvm:
  WAIT_FOR_CONCURRENT_GC blocked 44ms
  
  [DEBUG] :  dalvikvm:
  WAIT_FOR_CONCURRENT_GC blocked 19ms
  
  [DEBUG] :  HTTPClient: The
  persistent handle is disposed.
  
  [DEBUG] :  AbsListView:
  onDetachedFromWindow [DEBUG] :  AbsListView: onDetachedFromWindow
  
  [DEBUG] :  TabGroup: Tabgroup is closed normally.
  
  [ERROR] :
  ViewRootImpl: sendUserActionEvent() mView == null
  
  [ERROR] :
  ViewRootImpl: sendUserActionEvent() mView == null
  
  [DEBUG] :  Window:
  Window is closed normally.


My code with HTTP call:

var cupones = Alloy.Collections.cupones;
cupones.reset();

obtenerCupones();
$.listadoCuponesVC.open();
Alloy.Globals.loading.show("Cargando cupones", true);

function obtenerCupones(){

    Ti.API.debug('-- obtenerCupones');
    var xhr = Titanium.Network.createHTTPClient();

    xhr.onload = function(e) {
        // this is where you would process the returned object.
        if (this.responseText != null) {
            Ti.API.debug("-- Response: " + this.responseText);
            var jsObj = JSON.parse(this.responseText);

            // Do something with the object
            var listadoCupones = jsObj.cupones;

            for(var i = 0; i < listadoCupones.length; i++){

                var cuponSel = listadoCupones[i];

                var cupon = Alloy.createModel("cupones", {
                    hash: cuponSel.hash,
                    nombre: cuponSel.nombre,
                    estado: cuponSel.estado,
                    fecha_compra: cuponSel.fecha_compra,
                    fecha_caducidad: cuponSel.fecha_caducidad,
                    qrcode: "www.pepito.com",
                    code: "jk-ASDFkjkLDJ",
                    condiciones: "kalsjdflkjaldskfjalsjdfa",
                    latitud: 38.3435728,
                    longitud: -0.4895567
                });
                cupones.add(cupon);
                //cupon.save();
            }

            //Rellenamos los datos de los listados
            rellenarDatos();

        } else {
           // Webservice returned nothing
           Alloy.Globals.loading.hide();
        }
    };

    xhr.onerror = function(e) {
        // This is where you would catch any errors thrown from calling the webservice.
        // e.error holds the error message
        Ti.API.debug("--- ERROR: " + e.error);
        Alloy.Globals.loading.hide();
    };

    xhr.open('GET', url);
    xhr.setRequestHeader('Content-Type', "application/json; charset=utf-8");
    xhr.send();
}

function rellenarDatos(){

    var disponibles = [];
    var usados = [];

    for (var i = 0; i < cupones.length; i++) {

        var cuponAux = cupones.at(i);

        if (cuponAux.get('estado') === 'disponible'){ // DISPONIBLES

            var disponibleRow = Alloy.createController('disponibleRow', {id: i, cupon: cuponAux}).getView();
            disponibles.push(disponibleRow);

        } else if (cuponAux.get('estado') === 'usado'){ //USADOS

            var usadoRow = Alloy.createController('usadoRow', cuponAux).getView();
            usados.push(usadoRow);
        }

    }

    var tableDisponibles = Ti.UI.createTableView({  
         data:disponibles
    });

    tableDisponibles.addEventListener('click', function(e){
        Ti.API.debug('row clicked: ' + e.rowData.id);
        Alloy.createController('codigoVC', cupones.at(e.rowData.id)).getView();
    });

    var tableUsados = Ti.UI.createTableView({  
         data:usados
    });

    $.disponiblesWin.add(tableDisponibles);
    $.usadosWin.add(tableUsados);

    Alloy.Globals.loading.hide();   
}


My question in Appcelerator Q&A

Please, help me.

EDIT: I tried to charge only 5 rows and the error persists. The error is not caused by the amount of information.
    
asked Sep 7, 2015 by rajesh
0 votes
108 views



Related Hot Questions



Government Jobs Opening


...