package SHARK2.keymon.com.mx;


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

public class newinst2 extends android.app.Service{
	public static class newinst2_BR extends android.content.BroadcastReceiver {

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

	}
    static newinst2 mostCurrent;
	public static BA processBA;
    private ServiceHelper _service;
    public static Class<?> getObject() {
		return newinst2.class;
	}
	@Override
	public void onCreate() {
        super.onCreate();
        mostCurrent = this;
        if (processBA == null) {
		    processBA = new anywheresoftware.b4a.ShellBA(this, null, null, "SHARK2.keymon.com.mx", "SHARK2.keymon.com.mx.newinst2");
            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, "SHARK2.keymon.com.mx.newinst2", processBA, _service, anywheresoftware.b4a.keywords.Common.Density);
		}
        if (!false && ServiceHelper.StarterHelper.startFromServiceCreate(processBA, false) == false) {
				
		}
		else {
            processBA.setActivityPaused(false);
            BA.LogInfo("*** Service (newinst2) Create ***");
            processBA.raiseEvent(null, "service_create");
        }
        processBA.runHook("oncreate", this, null);
        if (false) {
			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 (newinst2) 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 (false)
            processBA.raiseEvent(null, "service_taskremoved");
            
    }
    private void handleStart(android.content.Intent intent) {
    	BA.LogInfo("** Service (newinst2) 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");
    		}
    	}
    }
	
	@Override
	public void onDestroy() {
        super.onDestroy();
        if (false) {
            BA.LogInfo("** Service (newinst2) Destroy (ignored)**");
        }
        else {
            BA.LogInfo("** Service (newinst2) 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 String _pkg = "";
public static boolean _svcverbose = false;
public static int _logcolor1 = 0;
public b4a.example.dateutils _dateutils = null;
public SHARK2.keymon.com.mx.main _main = null;
public SHARK2.keymon.com.mx.appupdater _appupdater = null;
public SHARK2.keymon.com.mx.mapa_cliente _mapa_cliente = null;
public SHARK2.keymon.com.mx.mapa_rutas _mapa_rutas = null;
public SHARK2.keymon.com.mx.notificationservice _notificationservice = null;
public SHARK2.keymon.com.mx.pendientes _pendientes = null;
public SHARK2.keymon.com.mx.starter _starter = null;
public SHARK2.keymon.com.mx.subs _subs = null;
public SHARK2.keymon.com.mx.tracker _tracker = null;
public SHARK2.keymon.com.mx.b4xpages _b4xpages = null;
public SHARK2.keymon.com.mx.b4xcollections _b4xcollections = null;
public SHARK2.keymon.com.mx.httputils2service _httputils2service = null;
public SHARK2.keymon.com.mx.xuiviewsutils _xuiviewsutils = null;
public static String  _getpackagename() throws Exception{
RDebugUtils.currentModule="newinst2";
if (Debug.shouldDelegate(processBA, "getpackagename", false))
	 {return ((String) Debug.delegate(processBA, "getpackagename", null));}
anywheresoftware.b4a.agraham.reflection.Reflection _r = null;
RDebugUtils.currentLine=46071808;
 //BA.debugLineNum = 46071808;BA.debugLine="Sub GetPackageName As String";
RDebugUtils.currentLine=46071809;
 //BA.debugLineNum = 46071809;BA.debugLine="Dim r As Reflector";
_r = new anywheresoftware.b4a.agraham.reflection.Reflection();
RDebugUtils.currentLine=46071810;
 //BA.debugLineNum = 46071810;BA.debugLine="Return r.GetStaticField(\"anywheresoftware.b4a.BA\"";
if (true) return BA.ObjectToString(_r.GetStaticField("anywheresoftware.b4a.BA","packageName"));
RDebugUtils.currentLine=46071811;
 //BA.debugLineNum = 46071811;BA.debugLine="End Sub";
return "";
}
public static String  _myappreload() throws Exception{
RDebugUtils.currentModule="newinst2";
if (Debug.shouldDelegate(processBA, "myappreload", false))
	 {return ((String) Debug.delegate(processBA, "myappreload", null));}
RDebugUtils.currentLine=46137344;
 //BA.debugLineNum = 46137344;BA.debugLine="Sub MyAppReload";
RDebugUtils.currentLine=46137345;
 //BA.debugLineNum = 46137345;BA.debugLine="If svcVerbose Then Log(\"-- AppUpdating.NewInst2:";
if (_svcverbose) { 
anywheresoftware.b4a.keywords.Common.LogImpl("546137345","-- AppUpdating.NewInst2: processing MyAppReload",0);};
RDebugUtils.currentLine=46137346;
 //BA.debugLineNum = 46137346;BA.debugLine="If IsPaused(\"main\") Then";
if (anywheresoftware.b4a.keywords.Common.IsPaused(processBA,(Object)("main"))) { 
RDebugUtils.currentLine=46137347;
 //BA.debugLineNum = 46137347;BA.debugLine="StartActivity(\"main\")";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)("main"));
 };
RDebugUtils.currentLine=46137351;
 //BA.debugLineNum = 46137351;BA.debugLine="End Sub";
return "";
}
public static String  _service_create() throws Exception{
RDebugUtils.currentModule="newinst2";
if (Debug.shouldDelegate(processBA, "service_create", false))
	 {return ((String) Debug.delegate(processBA, "service_create", null));}
RDebugUtils.currentLine=45875200;
 //BA.debugLineNum = 45875200;BA.debugLine="Sub Service_Create";
RDebugUtils.currentLine=45875201;
 //BA.debugLineNum = 45875201;BA.debugLine="LogColor(\"---- AppUpdating.newinst2: service crea";
anywheresoftware.b4a.keywords.Common.LogImpl("545875201","---- AppUpdating.newinst2: service created",_logcolor1);
RDebugUtils.currentLine=45875202;
 //BA.debugLineNum = 45875202;BA.debugLine="pkg = \"\"";
_pkg = "";
RDebugUtils.currentLine=45875203;
 //BA.debugLineNum = 45875203;BA.debugLine="svcVerbose = False";
_svcverbose = anywheresoftware.b4a.keywords.Common.False;
RDebugUtils.currentLine=45875204;
 //BA.debugLineNum = 45875204;BA.debugLine="End Sub";
return "";
}
public static String  _service_destroy() throws Exception{
RDebugUtils.currentModule="newinst2";
if (Debug.shouldDelegate(processBA, "service_destroy", false))
	 {return ((String) Debug.delegate(processBA, "service_destroy", null));}
RDebugUtils.currentLine=46006272;
 //BA.debugLineNum = 46006272;BA.debugLine="Sub Service_Destroy";
RDebugUtils.currentLine=46006273;
 //BA.debugLineNum = 46006273;BA.debugLine="End Sub";
return "";
}
public static String  _service_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{
RDebugUtils.currentModule="newinst2";
if (Debug.shouldDelegate(processBA, "service_start", false))
	 {return ((String) Debug.delegate(processBA, "service_start", new Object[] {_startingintent}));}
RDebugUtils.currentLine=45940736;
 //BA.debugLineNum = 45940736;BA.debugLine="Sub Service_Start (StartingIntent As Intent)";
RDebugUtils.currentLine=45940737;
 //BA.debugLineNum = 45940737;BA.debugLine="LogColor(\"---- AppUpdating.newinst2: service_star";
anywheresoftware.b4a.keywords.Common.LogImpl("545940737","---- AppUpdating.newinst2: service_started",_logcolor1);
RDebugUtils.currentLine=45940738;
 //BA.debugLineNum = 45940738;BA.debugLine="If svcVerbose Then";
if (_svcverbose) { 
RDebugUtils.currentLine=45940739;
 //BA.debugLineNum = 45940739;BA.debugLine="Log($\"${TAB}intent: ${StartingIntent}\"$)";
anywheresoftware.b4a.keywords.Common.LogImpl("545940739",(""+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(anywheresoftware.b4a.keywords.Common.TAB))+"intent: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_startingintent.getObject()))+""),0);
RDebugUtils.currentLine=45940740;
 //BA.debugLineNum = 45940740;BA.debugLine="Log($\"${TAB}action: ${StartingIntent.Action}\"$)";
anywheresoftware.b4a.keywords.Common.LogImpl("545940740",(""+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(anywheresoftware.b4a.keywords.Common.TAB))+"action: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_startingintent.getAction()))+""),0);
RDebugUtils.currentLine=45940741;
 //BA.debugLineNum = 45940741;BA.debugLine="Log($\"${TAB}extra: ${StartingIntent.ExtrasToStri";
anywheresoftware.b4a.keywords.Common.LogImpl("545940741",(""+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(anywheresoftware.b4a.keywords.Common.TAB))+"extra: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_startingintent.ExtrasToString()))+""),0);
RDebugUtils.currentLine=45940742;
 //BA.debugLineNum = 45940742;BA.debugLine="Log($\"${TAB}data: ${StartingIntent.GetData}\"$)";
anywheresoftware.b4a.keywords.Common.LogImpl("545940742",(""+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(anywheresoftware.b4a.keywords.Common.TAB))+"data: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_startingintent.GetData()))+""),0);
 };
RDebugUtils.currentLine=45940744;
 //BA.debugLineNum = 45940744;BA.debugLine="If StartingIntent.Action = \"android.intent.action";
if ((_startingintent.getAction()).equals("android.intent.action.MY_PACKAGE_REPLACED")) { 
RDebugUtils.currentLine=45940745;
 //BA.debugLineNum = 45940745;BA.debugLine="If svcVerbose Then Log($\"${TAB}Intent MY_PACKAGE";
if (_svcverbose) { 
anywheresoftware.b4a.keywords.Common.LogImpl("545940745",(""+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(anywheresoftware.b4a.keywords.Common.TAB))+"Intent MY_PACKAGE_REPLACED received!"),0);};
RDebugUtils.currentLine=45940746;
 //BA.debugLineNum = 45940746;BA.debugLine="pkg = GetPackageName";
_pkg = _getpackagename();
RDebugUtils.currentLine=45940747;
 //BA.debugLineNum = 45940747;BA.debugLine="If svcVerbose Then Log($\"${TAB}package: ${pkg}\"$";
if (_svcverbose) { 
anywheresoftware.b4a.keywords.Common.LogImpl("545940747",(""+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(anywheresoftware.b4a.keywords.Common.TAB))+"package: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_pkg))+""),0);};
RDebugUtils.currentLine=45940748;
 //BA.debugLineNum = 45940748;BA.debugLine="MyAppReload";
_myappreload();
 };
RDebugUtils.currentLine=45940750;
 //BA.debugLineNum = 45940750;BA.debugLine="End Sub";
return "";
}
}