Hi guys
I have a problem to install an apk previously downloaded from a server, then start to finish downloading the installation with intent () but nothing happens ...... not start the installation. Help me with this please.
show the code
module.exports = function(win) { //consultamos un json por actualizaciones var version = Ti.Network.createHTTPClient(); version.onload = function() { var version = "1.3"; var data = JSON.parse(this.responseText); //alert(data.version); if(version !== '1.2') { var descarga = Ti.UI.createButton({ title:'Actualizar', top:'25dp', //left:'9%', backgroundColor:'#555', width:'90%', height:'15%', color:'#FFF', font:{fontFamily:'Cicle_Semi', fontSize:'35%'}, borderRadius:5 }); win.add(descarga); descarga.addEventListener('click',function() { var ind=Titanium.UI.createProgressBar({ width:'200dp', //height:'100dp', min:0, max:1, value:0, top:'100dp', message:'Descargando Actualizaciones..', font:{fontSize:12, fontWeight:'bold'}, color:'#333', zIndex:9 }); win.add(ind); ind.show(); var xhr = Ti.Network.createHTTPClient(); xhr.onload = function() { var f = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory,'bestado.apk'); f.write(this.responseData); Ti.App.fireEvent('downloaded', {filepath:f.nativePath}); }; xhr.ondatastream = function(e) { ind.value = e.progress ; Ti.API.info('ONSENDSTREAM - PROGRESS: ' + e.progress); }; timeout: 10000; xhr.open('GET',Ti.App.Properties.getString("URL")+'bestado.apk'); xhr.send(); Ti.App.addEventListener('downloaded', function(e) { Ti.API.info(e.filepath); ind.hide(); var intent = Ti.Android.createIntent({ action: Ti.Android.ACTION_VIEW, data: e.filepath, type: "application/vnd.android.package-archive", packageName: "com.android.packageinstaller", flag: "0x10000000" }); Ti.Android.currentActivity.startActivity(intent); }); }); }else { //alert('tienes que actualizar tu sistema'); } }; version.open('GET',Ti.App.Properties.getString("URL")+'json/update.php'); version.send(); };First I make a validation if some file exists on the server with a new version of the apk, then download and create a trigger to initiate the intent (), but does nothing. Any idea what happened?
Android sdk 3.4