private String callhostsub(String sub, Object[] args, boolean runonguithread)
{
try
{
sub = sub.toLowerCase();
if (args == null)
args = new String[0];
if (!ba.subExists(sub))
{
saveerror("CallHostSub : Sub " + sub + " not found!");
return null;
}
// we need to check the thread we are on at event or call time
// because we could be newed on main thread and invoked on another
if (!runonguithread || (Thread.currentThread() == guithread))
{
String ret;
// use raiseEvent2 to let it run during Activity_Create
ret = (String) ba.raiseEvent2(this, true, sub, false, args);
// raiseEvent returns null during Activity_Create
if (ret == null)
{
// unlikely to get this now but left in just in case
String msg = "CallHostSub : " + sub + " returned Null";
saveerror(msg);
Log.e("B4A", msg + " at line " + linenum);
}
return ret;
}
TaskId += 1;
ba.raiseEventFromDifferentThread(this, this, TaskId, sub, false, args);
} catch (Exception e)
{
String msg = "CallHostSub : " + sub + " - " + e.toString() + " - " + e.getMessage();
saveerror(msg);
Log.e("B4A", msg + " at line " + linenum);
Log.e("B4A", "", e); // stack trace
}
return "";
}