package reparto_medicomed.keymon.lat;


import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.objects.ServiceHelper;
import anywheresoftware.b4a.debug.*;

public class starter extends android.app.Service{
	public static class starter_BR extends android.content.BroadcastReceiver {

		@Override
		public void onReceive(android.content.Context context, android.content.Intent intent) {
            BA.LogInfo("** Receiver (starter) OnReceive **");
			android.content.Intent in = new android.content.Intent(context, starter.class);
			if (intent != null)
				in.putExtra("b4a_internal_intent", intent);
            ServiceHelper.StarterHelper.startServiceFromReceiver (context, in, true, BA.class);
		}

	}
    static starter mostCurrent;
	public static BA processBA;
    private ServiceHelper _service;
    public static Class<?> getObject() {
		return starter.class;
	}
	@Override
	public void onCreate() {
        super.onCreate();
        mostCurrent = this;
        if (processBA == null) {
		    processBA = new BA(this, null, null, "reparto_medicomed.keymon.lat", "reparto_medicomed.keymon.lat.starter");
            if (BA.isShellModeRuntimeCheck(processBA)) {
                processBA.raiseEvent2(null, true, "SHELL", false);
		    }
            try {
                Class.forName(BA.applicationContext.getPackageName() + ".main").getMethod("initializeProcessGlobals").invoke(null, null);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            processBA.loadHtSubs(this.getClass());
            ServiceHelper.init();
        }
        _service = new ServiceHelper(this);
        processBA.service = this;
        
        if (BA.isShellModeRuntimeCheck(processBA)) {
			processBA.raiseEvent2(null, true, "CREATE", true, "reparto_medicomed.keymon.lat.starter", processBA, _service, anywheresoftware.b4a.keywords.Common.Density);
		}
        if (!true && ServiceHelper.StarterHelper.startFromServiceCreate(processBA, false) == false) {
				
		}
		else {
            processBA.setActivityPaused(false);
            BA.LogInfo("*** Service (starter) Create ***");
            processBA.raiseEvent(null, "service_create");
        }
        processBA.runHook("oncreate", this, null);
        if (true) {
			if (ServiceHelper.StarterHelper.runWaitForLayouts() == false) {
                BA.LogInfo("stopping spontaneous created service");
                stopSelf();
            }
		}
    }
		@Override
	public void onStart(android.content.Intent intent, int startId) {
		onStartCommand(intent, 0, 0);
    }
    @Override
    public int onStartCommand(final android.content.Intent intent, int flags, int startId) {
    	if (ServiceHelper.StarterHelper.onStartCommand(processBA, new Runnable() {
            public void run() {
                handleStart(intent);
            }}))
			;
		else {
			ServiceHelper.StarterHelper.addWaitForLayout (new Runnable() {
				public void run() {
                    processBA.setActivityPaused(false);
                    BA.LogInfo("** Service (starter) Create **");
                    processBA.raiseEvent(null, "service_create");
					handleStart(intent);
                    ServiceHelper.StarterHelper.removeWaitForLayout();
				}
			});
		}
        processBA.runHook("onstartcommand", this, new Object[] {intent, flags, startId});
		return android.app.Service.START_NOT_STICKY;
    }
    public void onTaskRemoved(android.content.Intent rootIntent) {
        super.onTaskRemoved(rootIntent);
        if (true)
            processBA.raiseEvent(null, "service_taskremoved");
            
    }
    private void handleStart(android.content.Intent intent) {
    	BA.LogInfo("** Service (starter) Start **");
    	java.lang.reflect.Method startEvent = processBA.htSubs.get("service_start");
    	if (startEvent != null) {
    		if (startEvent.getParameterTypes().length > 0) {
    			anywheresoftware.b4a.objects.IntentWrapper iw = ServiceHelper.StarterHelper.handleStartIntent(intent, _service, processBA);
    			processBA.raiseEvent(null, "service_start", iw);
    		}
    		else {
    			processBA.raiseEvent(null, "service_start");
    		}
    	}
    }

	public void onTimeout(int startId) {
        BA.LogInfo("** Service (starter) Timeout **");
        anywheresoftware.b4a.objects.collections.Map params = new anywheresoftware.b4a.objects.collections.Map();
        params.Initialize();
        params.Put("StartId", startId);
        processBA.raiseEvent(null, "service_timeout", params);
            
    }
	@Override
	public void onDestroy() {
        super.onDestroy();
        if (true) {
            BA.LogInfo("** Service (starter) Destroy (ignored)**");
        }
        else {
            BA.LogInfo("** Service (starter) Destroy **");
		    processBA.raiseEvent(null, "service_destroy");
            processBA.service = null;
		    mostCurrent = null;
		    processBA.setActivityPaused(true);
            processBA.runHook("ondestroy", this, null);
        }
	}

@Override
	public android.os.IBinder onBind(android.content.Intent intent) {
		return null;
	}public anywheresoftware.b4a.keywords.Common __c = null;
public static anywheresoftware.b4a.objects.RuntimePermissions _rp = null;
public static uk.co.martinpearman.b4a.fusedlocationprovider.FusedLocationProviderWrapper _flp = null;
public static boolean _flpstarted = false;
public static anywheresoftware.b4a.sql.SQL _skmt = null;
public static String _ruta = "";
public static anywheresoftware.b4a.objects.Serial.BluetoothAdmin _btadmin = null;
public static boolean _bluetoothstate = false;
public static anywheresoftware.b4a.objects.Timer _timer1 = null;
public static int _interval = 0;
public static String _trackeractividad = "";
public static String _pushserviceactividad = "";
public static String _mac_impresora = "";
public static anywheresoftware.b4a.keywords.StringBuilderWrapper _logs = null;
public static anywheresoftware.b4a.phone.Phone.LogCat _logcat = null;
public static String _sharedfolder = "";
public static anywheresoftware.b4a.gps.LocationWrapper _cedislocation = null;
public static reparto_medicomed.keymon.lat.dbrequestmanager _reqmanager = null;
public static String _server = "";
public static String _muestraprogreso = "";
public static anywheresoftware.b4a.sql.SQL.CursorWrapper _c = null;
public b4a.example.dateutils _dateutils = null;
public reparto_medicomed.keymon.lat.main _main = null;
public reparto_medicomed.keymon.lat.appupdater _appupdater = null;
public reparto_medicomed.keymon.lat.foto _foto = null;
public reparto_medicomed.keymon.lat.mapa_cliente _mapa_cliente = null;
public reparto_medicomed.keymon.lat.mapa_rutas _mapa_rutas = null;
public reparto_medicomed.keymon.lat.subs _subs = null;
public reparto_medicomed.keymon.lat.tracker _tracker = null;
public reparto_medicomed.keymon.lat.newinst2 _newinst2 = null;
public reparto_medicomed.keymon.lat.b4xpages _b4xpages = null;
public reparto_medicomed.keymon.lat.b4xcollections _b4xcollections = null;
public reparto_medicomed.keymon.lat.httputils2service _httputils2service = null;
public reparto_medicomed.keymon.lat.xuiviewsutils _xuiviewsutils = null;
public static boolean  _application_error(anywheresoftware.b4a.objects.B4AException _error,String _stacktrace) throws Exception{
 //BA.debugLineNum = 81;BA.debugLine="Sub Application_Error (Error As Exception, StackTr";
 //BA.debugLineNum = 82;BA.debugLine="Return True";
if (true) return anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 83;BA.debugLine="End Sub";
return false;
}
public static String  _envia_ultima_gps() throws Exception{
reparto_medicomed.keymon.lat.dbrequestmanager._dbcommand _cmd = null;
 //BA.debugLineNum = 95;BA.debugLine="Sub ENVIA_ULTIMA_GPS";
 //BA.debugLineNum = 96;BA.debugLine="If IsConnectedToInternet Then";
if (_isconnectedtointernet()) { 
 //BA.debugLineNum = 97;BA.debugLine="Log(\"Con internet, enviamos UTR!\")";
anywheresoftware.b4a.keywords.Common.LogImpl("030736386","Con internet, enviamos UTR!",0);
 //BA.debugLineNum = 98;BA.debugLine="Dim skmt As SQL";
_skmt = new anywheresoftware.b4a.sql.SQL();
 //BA.debugLineNum = 99;BA.debugLine="Dim cmd As DBCommand";
_cmd = new reparto_medicomed.keymon.lat.dbrequestmanager._dbcommand();
 //BA.debugLineNum = 100;BA.debugLine="Dim reqManager As DBRequestManager";
_reqmanager = new reparto_medicomed.keymon.lat.dbrequestmanager();
 //BA.debugLineNum = 101;BA.debugLine="reqManager.Initialize(Me, server)";
_reqmanager._initialize /*String*/ (processBA,starter.getObject(),_server);
 //BA.debugLineNum = 103;BA.debugLine="skmt.Initialize(ruta,\"kmt.db\", True)";
_skmt.Initialize(_ruta,"kmt.db",anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 105;BA.debugLine="skmt.Initialize(ruta,\"kmt.db\", True)";
_skmt.Initialize(_ruta,"kmt.db",anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 106;BA.debugLine="If B4XPages.MainPage.logger Then LogColor(\"Inici";
if (mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
anywheresoftware.b4a.keywords.Common.LogImpl("030736395","Iniciamos ENVIA_ULTIMA_GPS",anywheresoftware.b4a.keywords.Common.Colors.Red);};
 //BA.debugLineNum = 107;BA.debugLine="DateTime.TimeFormat = \"HHmmss\"";
anywheresoftware.b4a.keywords.Common.DateTime.setTimeFormat("HHmmss");
 //BA.debugLineNum = 108;BA.debugLine="B4XPages.MainPage.ultimaActualizacionGPS = DateT";
mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._ultimaactualizaciongps /*String*/  = anywheresoftware.b4a.keywords.Common.DateTime.Time(anywheresoftware.b4a.keywords.Common.DateTime.getNow());
 //BA.debugLineNum = 109;BA.debugLine="cmd.Initialize";
_cmd.Initialize();
 //BA.debugLineNum = 110;BA.debugLine="cmd.Name = \"select_fechat\"";
_cmd.Name /*String*/  = "select_fechat";
 //BA.debugLineNum = 111;BA.debugLine="reqManager.ExecuteQuery(cmd , 0, \"fechat\")";
_reqmanager._executequery /*String*/ (_cmd,(int) (0),(Object)("fechat"));
 //BA.debugLineNum = 113;BA.debugLine="Dim cmd As DBCommand";
_cmd = new reparto_medicomed.keymon.lat.dbrequestmanager._dbcommand();
 //BA.debugLineNum = 114;BA.debugLine="cmd.Initialize";
_cmd.Initialize();
 //BA.debugLineNum = 115;BA.debugLine="cmd.Name = \"UPDATE_MEDICOMEDv2_ACTUALR3_GPS\"";
_cmd.Name /*String*/  = "UPDATE_MEDICOMEDv2_ACTUALR3_GPS";
 //BA.debugLineNum = 116;BA.debugLine="cmd.Parameters = Array As Object(B4XPages.MainPa";
_cmd.Parameters /*Object[]*/  = new Object[]{(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._montoactual /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._clientestotal /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._clientesventa /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._clientesvisitados /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._lat_gps /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._lon_gps /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._batt /*int*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._montorechazado /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._montoentregado /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._clientestotal /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._porvisitar /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._entregas /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._rechazos /*String*/ ),(Object)(anywheresoftware.b4a.keywords.Common.Application.getVersionName()),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._almacen /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._rutapreventa /*String*/ )};
 //BA.debugLineNum = 117;BA.debugLine="If B4XPages.MainPage.logger Then Log($\"montoActu";
if (mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
anywheresoftware.b4a.keywords.Common.LogImpl("030736406",("montoActual: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._montoactual /*String*/ ))+", cTotal: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._clientestotal /*String*/ ))+", cVenta: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._clientesventa /*String*/ ))+", cVisitados: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._clientesvisitados /*String*/ ))+", "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._lat_gps /*String*/ ))+", "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._lon_gps /*String*/ ))+", Batt: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._batt /*int*/ ))+", montoRechazado: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._montorechazado /*String*/ ))+", montoEntregado: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._montoentregado /*String*/ ))+", porVisitar: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._porvisitar /*String*/ ))+", entregas: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._entregas /*String*/ ))+", rechazos: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._rechazos /*String*/ ))+", Almacen: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._almacen /*String*/ ))+", Ruta: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._b4xpages._mainpage /*reparto_medicomed.keymon.lat.b4xmainpage*/ (processBA)._rutapreventa /*String*/ ))+""),0);};
 //BA.debugLineNum = 119;BA.debugLine="reqManager.ExecuteCommand(cmd, \"inst_visitas\")";
_reqmanager._executecommand /*String*/ (_cmd,(Object)("inst_visitas"));
 //BA.debugLineNum = 120;BA.debugLine="skmt.ExecNonQuery2(\"Update cat_variables set CAT";
_skmt.ExecNonQuery2("Update cat_variables set CAT_VA_VALOR = ?  WHERE CAT_VA_DESCRIPCION = ?",anywheresoftware.b4a.keywords.Common.ArrayToList(new String[]{anywheresoftware.b4a.keywords.Common.DateTime.Time(anywheresoftware.b4a.keywords.Common.DateTime.getNow()),"HoraIngreso"}));
 //BA.debugLineNum = 123;BA.debugLine="Timer1.Enabled = False";
_timer1.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 124;BA.debugLine="Timer1.Interval = Interval * 1000";
_timer1.setInterval((long) (_interval*1000));
 //BA.debugLineNum = 125;BA.debugLine="Timer1.Enabled = True";
_timer1.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 }else {
 //BA.debugLineNum = 127;BA.debugLine="Log(\"Sin conexión a internet, no se envió UTR!\")";
anywheresoftware.b4a.keywords.Common.LogImpl("030736416","Sin conexión a internet, no se envió UTR!",0);
 };
 //BA.debugLineNum = 129;BA.debugLine="End Sub";
return "";
}
public static boolean  _isconnectedtointernet() throws Exception{
anywheresoftware.b4a.agraham.reflection.Reflection _r = null;
 //BA.debugLineNum = 136;BA.debugLine="Sub IsConnectedToInternet As Boolean 'ignore";
 //BA.debugLineNum = 137;BA.debugLine="Dim r As Reflector";
_r = new anywheresoftware.b4a.agraham.reflection.Reflection();
 //BA.debugLineNum = 138;BA.debugLine="r.Target = r.GetContext";
_r.Target = (Object)(_r.GetContext(processBA));
 //BA.debugLineNum = 139;BA.debugLine="r.Target = r.RunMethod2(\"getSystemService\", \"conn";
_r.Target = _r.RunMethod2("getSystemService","connectivity","java.lang.String");
 //BA.debugLineNum = 140;BA.debugLine="r.Target = r.RunMethod(\"getActiveNetworkInfo\")";
_r.Target = _r.RunMethod("getActiveNetworkInfo");
 //BA.debugLineNum = 141;BA.debugLine="If r.Target <> Null Then";
if (_r.Target!= null) { 
 //BA.debugLineNum = 142;BA.debugLine="Return r.RunMethod(\"isConnectedOrConnecting\")";
if (true) return BA.ObjectToBoolean(_r.RunMethod("isConnectedOrConnecting"));
 };
 //BA.debugLineNum = 144;BA.debugLine="Return False";
if (true) return anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 145;BA.debugLine="End Sub";
return false;
}
public static String  _jobdone(reparto_medicomed.keymon.lat.httpjob _job) throws Exception{
 //BA.debugLineNum = 147;BA.debugLine="Sub JobDone(Job As HttpJob)";
 //BA.debugLineNum = 151;BA.debugLine="If Job.Success = False Then";
if (_job._success /*boolean*/ ==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 153;BA.debugLine="If Job.ErrorMessage.Contains(\"failed to connect\"";
if (_job._errormessage /*String*/ .contains("failed to connect") || _job._errormessage /*String*/ .contains("Failed to connect")) { 
 //BA.debugLineNum = 154;BA.debugLine="ToastMessageShow(\"!Hubo un error contactando al";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("!Hubo un error contactando al servidor, por favor revise su conexión!"),anywheresoftware.b4a.keywords.Common.True);
 };
 }else {
 };
 //BA.debugLineNum = 160;BA.debugLine="End Sub";
return "";
}
public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 6;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 9;BA.debugLine="Public rp As RuntimePermissions";
_rp = new anywheresoftware.b4a.objects.RuntimePermissions();
 //BA.debugLineNum = 10;BA.debugLine="Public FLP As FusedLocationProvider";
_flp = new uk.co.martinpearman.b4a.fusedlocationprovider.FusedLocationProviderWrapper();
 //BA.debugLineNum = 11;BA.debugLine="Private flpStarted As Boolean";
_flpstarted = false;
 //BA.debugLineNum = 12;BA.debugLine="Dim skmt As SQL";
_skmt = new anywheresoftware.b4a.sql.SQL();
 //BA.debugLineNum = 13;BA.debugLine="Dim ruta As String";
_ruta = "";
 //BA.debugLineNum = 14;BA.debugLine="Private BTAdmin As BluetoothAdmin";
_btadmin = new anywheresoftware.b4a.objects.Serial.BluetoothAdmin();
 //BA.debugLineNum = 15;BA.debugLine="Public BluetoothState As Boolean";
_bluetoothstate = false;
 //BA.debugLineNum = 16;BA.debugLine="Dim Timer1 As Timer";
_timer1 = new anywheresoftware.b4a.objects.Timer();
 //BA.debugLineNum = 17;BA.debugLine="Dim Interval As Int = 300";
_interval = (int) (300);
 //BA.debugLineNum = 21;BA.debugLine="Dim trackerActividad  As String = \"501231235959\"";
_trackeractividad = "501231235959";
 //BA.debugLineNum = 22;BA.debugLine="Dim pushServiceActividad As String = \"50123123595";
_pushserviceactividad = "501231235959";
 //BA.debugLineNum = 24;BA.debugLine="Dim MAC_IMPRESORA As String";
_mac_impresora = "";
 //BA.debugLineNum = 25;BA.debugLine="Private logs As StringBuilder";
_logs = new anywheresoftware.b4a.keywords.StringBuilderWrapper();
 //BA.debugLineNum = 26;BA.debugLine="Private logcat As LogCat";
_logcat = new anywheresoftware.b4a.phone.Phone.LogCat();
 //BA.debugLineNum = 27;BA.debugLine="Public SharedFolder As String 'Para actualizar ap";
_sharedfolder = "";
 //BA.debugLineNum = 28;BA.debugLine="Dim cedisLocation As Location";
_cedislocation = new anywheresoftware.b4a.gps.LocationWrapper();
 //BA.debugLineNum = 29;BA.debugLine="Dim reqManager As DBRequestManager";
_reqmanager = new reparto_medicomed.keymon.lat.dbrequestmanager();
 //BA.debugLineNum = 30;BA.debugLine="Dim server As String = \"http://187.189.244.154:17";
_server = "http://187.189.244.154:1781";
 //BA.debugLineNum = 34;BA.debugLine="Dim muestraProgreso = 0";
_muestraprogreso = BA.NumberToString(0);
 //BA.debugLineNum = 35;BA.debugLine="Dim c As Cursor";
_c = new anywheresoftware.b4a.sql.SQL.CursorWrapper();
 //BA.debugLineNum = 36;BA.debugLine="End Sub";
return "";
}
public static String  _service_create() throws Exception{
 //BA.debugLineNum = 38;BA.debugLine="Sub Service_Create";
 //BA.debugLineNum = 41;BA.debugLine="ruta = File.DirInternal 'Ruta de la base de datos";
_ruta = anywheresoftware.b4a.keywords.Common.File.getDirInternal();
 //BA.debugLineNum = 43;BA.debugLine="If Not(File.Exists(ruta, \"kmt.db\")) Then File.Cop";
if (anywheresoftware.b4a.keywords.Common.Not(anywheresoftware.b4a.keywords.Common.File.Exists(_ruta,"kmt.db"))) { 
anywheresoftware.b4a.keywords.Common.File.Copy(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"kmt.db",_ruta,"kmt.db");};
 //BA.debugLineNum = 44;BA.debugLine="Log(ruta)";
anywheresoftware.b4a.keywords.Common.LogImpl("030343174",_ruta,0);
 //BA.debugLineNum = 45;BA.debugLine="skmt.Initialize(ruta,\"kmt.db\", True)";
_skmt.Initialize(_ruta,"kmt.db",anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 59;BA.debugLine="Timer1.Initialize(\"Timer1\", Interval * 1000)";
_timer1.Initialize(processBA,"Timer1",(long) (_interval*1000));
 //BA.debugLineNum = 60;BA.debugLine="Timer1.Enabled = True";
_timer1.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 61;BA.debugLine="SharedFolder = rp.GetSafeDirDefaultExternal(\"\")";
_sharedfolder = _rp.GetSafeDirDefaultExternal("");
 //BA.debugLineNum = 62;BA.debugLine="cedisLocation.Initialize";
_cedislocation.Initialize();
 //BA.debugLineNum = 65;BA.debugLine="cedisLocation.Latitude = \"0\"";
_cedislocation.setLatitude((double)(Double.parseDouble("0")));
 //BA.debugLineNum = 66;BA.debugLine="cedisLocation.Longitude = \"0\"";
_cedislocation.setLongitude((double)(Double.parseDouble("0")));
 //BA.debugLineNum = 67;BA.debugLine="End Sub";
return "";
}
public static String  _service_destroy() throws Exception{
 //BA.debugLineNum = 85;BA.debugLine="Sub Service_Destroy";
 //BA.debugLineNum = 87;BA.debugLine="End Sub";
return "";
}
public static String  _service_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{
 //BA.debugLineNum = 69;BA.debugLine="Sub Service_Start (StartingIntent As Intent)";
 //BA.debugLineNum = 70;BA.debugLine="Service.StopAutomaticForeground 'Starter service";
mostCurrent._service.StopAutomaticForeground();
 //BA.debugLineNum = 74;BA.debugLine="End Sub";
return "";
}
public static String  _service_taskremoved() throws Exception{
 //BA.debugLineNum = 76;BA.debugLine="Sub Service_TaskRemoved";
 //BA.debugLineNum = 78;BA.debugLine="End Sub";
return "";
}
public static String  _timer1_tick() throws Exception{
 //BA.debugLineNum = 89;BA.debugLine="Private Sub Timer1_Tick";
 //BA.debugLineNum = 92;BA.debugLine="ENVIA_ULTIMA_GPS";
_envia_ultima_gps();
 //BA.debugLineNum = 93;BA.debugLine="End Sub";
return "";
}
}
