send broadcast with intents
This commit is contained in:
parent
2361c758c9
commit
5272b56032
@ -368,6 +368,10 @@ public class Action
|
|||||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.unknown));
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.unknown));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(this.getAction().equals(Action_Enum.sendBroadcast))
|
||||||
|
{
|
||||||
|
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; ").replace(Action.intentPairSeparator, "/"));
|
||||||
|
}
|
||||||
else if (parameter2 != null && parameter2.length() > 0)
|
else if (parameter2 != null && parameter2.length() > 0)
|
||||||
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; "));
|
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; "));
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,9 @@ public class Actions
|
|||||||
{
|
{
|
||||||
String[] parts = action.split(Action.actionParameter2Split);
|
String[] parts = action.split(Action.actionParameter2Split);
|
||||||
broadcastIntent.setAction(parts[0]);
|
broadcastIntent.setAction(parts[0]);
|
||||||
add params
|
|
||||||
|
String[] intentparts = parts[1].split(";");
|
||||||
|
broadcastIntent = packParametersIntoIntent(broadcastIntent, intentparts, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
broadcastIntent.setAction(action);
|
broadcastIntent.setAction(action);
|
||||||
@ -1017,8 +1019,6 @@ public class Actions
|
|||||||
{
|
{
|
||||||
Intent externalActivityIntent;
|
Intent externalActivityIntent;
|
||||||
|
|
||||||
int paramsStartIndex;
|
|
||||||
|
|
||||||
if (!startByAction)
|
if (!startByAction)
|
||||||
{
|
{
|
||||||
// selected by activity
|
// selected by activity
|
||||||
@ -1030,8 +1030,6 @@ public class Actions
|
|||||||
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Starting app by activity: " + packageName + " " + className, 3);
|
Miscellaneous.logEvent("i", "StartOtherApp", "Starting app by activity: " + packageName + " " + className, 3);
|
||||||
|
|
||||||
paramsStartIndex = 2;
|
|
||||||
|
|
||||||
externalActivityIntent = new Intent(Intent.ACTION_MAIN);
|
externalActivityIntent = new Intent(Intent.ACTION_MAIN);
|
||||||
externalActivityIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
externalActivityIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||||
|
|
||||||
@ -1059,86 +1057,7 @@ public class Actions
|
|||||||
externalActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
externalActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
|
||||||
// Pack intents
|
// Pack intents
|
||||||
for (int i = 3; i < params.length; i++)
|
externalActivityIntent = packParametersIntoIntent(externalActivityIntent, params, 3);
|
||||||
{
|
|
||||||
String[] singleParam = params[i].split(Action.intentPairSeparator);
|
|
||||||
|
|
||||||
/*Class c = Class.forName(singleParam[0]);
|
|
||||||
for(Method m : c.getMethods())
|
|
||||||
{
|
|
||||||
if(m.getName().startsWith("parse"))
|
|
||||||
{
|
|
||||||
Object o = m.invoke(null, singleParam[0]);
|
|
||||||
externalActivityIntent.putExtra(singleParam[1], o);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (singleParam[0].equals("boolean"))
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
|
||||||
externalActivityIntent.putExtra(singleParam[1], Boolean.parseBoolean(singleParam[2]));
|
|
||||||
}
|
|
||||||
else if (singleParam[0].equals("byte"))
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
|
||||||
externalActivityIntent.putExtra(singleParam[1], Byte.parseByte(singleParam[2]));
|
|
||||||
}
|
|
||||||
else if (singleParam[0].equals("char"))
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
|
||||||
externalActivityIntent.putExtra(singleParam[1], singleParam[2].charAt(0));
|
|
||||||
}
|
|
||||||
else if (singleParam[0].equals("CharSequence"))
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
|
||||||
externalActivityIntent.putExtra(singleParam[1], (CharSequence) singleParam[2]);
|
|
||||||
}
|
|
||||||
else if (singleParam[0].equals("double"))
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
|
||||||
externalActivityIntent.putExtra(singleParam[1], Double.parseDouble(singleParam[2]));
|
|
||||||
}
|
|
||||||
else if (singleParam[0].equals("float"))
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
|
||||||
externalActivityIntent.putExtra(singleParam[1], Float.parseFloat(singleParam[2]));
|
|
||||||
}
|
|
||||||
else if (singleParam[0].equals("int"))
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
|
||||||
externalActivityIntent.putExtra(singleParam[1], Integer.parseInt(singleParam[2]));
|
|
||||||
}
|
|
||||||
else if (singleParam[0].equals("long"))
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
|
||||||
externalActivityIntent.putExtra(singleParam[1], Long.parseLong(singleParam[2]));
|
|
||||||
}
|
|
||||||
else if (singleParam[0].equals("short"))
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
|
||||||
externalActivityIntent.putExtra(singleParam[1], Short.parseShort(singleParam[2]));
|
|
||||||
}
|
|
||||||
else if (singleParam[0].equals("Uri"))
|
|
||||||
{
|
|
||||||
if (singleParam[1].equalsIgnoreCase("IntentData"))
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with value " + singleParam[2] + " as standard data parameter.", 3);
|
|
||||||
externalActivityIntent.setData(Uri.parse(singleParam[2]));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
|
||||||
externalActivityIntent.putExtra(singleParam[1], Uri.parse(singleParam[2]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (singleParam[0].equals("String"))
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
|
||||||
externalActivityIntent.putExtra(singleParam[1], singleParam[2]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Miscellaneous.logEvent("w", "StartOtherApp", "Unknown type of parameter " + singleParam[0] + " found. Name " + singleParam[1] + " and value " + singleParam[2], 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params[2].equals(ActivityManageActionStartActivity.startByActivityString))
|
if (params[2].equals(ActivityManageActionStartActivity.startByActivityString))
|
||||||
automationServerRef.startActivity(externalActivityIntent);
|
automationServerRef.startActivity(externalActivityIntent);
|
||||||
@ -1152,6 +1071,92 @@ public class Actions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Intent packParametersIntoIntent(Intent intent, String[] params, int startIndex)
|
||||||
|
{
|
||||||
|
for (int i = startIndex; i < params.length; i++)
|
||||||
|
{
|
||||||
|
String[] singleParam = params[i].split(Action.intentPairSeparator);
|
||||||
|
|
||||||
|
/*Class c = Class.forName(singleParam[0]);
|
||||||
|
for(Method m : c.getMethods())
|
||||||
|
{
|
||||||
|
if(m.getName().startsWith("parse"))
|
||||||
|
{
|
||||||
|
Object o = m.invoke(null, singleParam[0]);
|
||||||
|
externalActivityIntent.putExtra(singleParam[1], o);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if (singleParam[0].equals("boolean"))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
|
intent.putExtra(singleParam[1], Boolean.parseBoolean(singleParam[2]));
|
||||||
|
}
|
||||||
|
else if (singleParam[0].equals("byte"))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
|
intent.putExtra(singleParam[1], Byte.parseByte(singleParam[2]));
|
||||||
|
}
|
||||||
|
else if (singleParam[0].equals("char"))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
|
intent.putExtra(singleParam[1], singleParam[2].charAt(0));
|
||||||
|
}
|
||||||
|
else if (singleParam[0].equals("CharSequence"))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
|
intent.putExtra(singleParam[1], (CharSequence) singleParam[2]);
|
||||||
|
}
|
||||||
|
else if (singleParam[0].equals("double"))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
|
intent.putExtra(singleParam[1], Double.parseDouble(singleParam[2]));
|
||||||
|
}
|
||||||
|
else if (singleParam[0].equals("float"))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
|
intent.putExtra(singleParam[1], Float.parseFloat(singleParam[2]));
|
||||||
|
}
|
||||||
|
else if (singleParam[0].equals("int"))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
|
intent.putExtra(singleParam[1], Integer.parseInt(singleParam[2]));
|
||||||
|
}
|
||||||
|
else if (singleParam[0].equals("long"))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
|
intent.putExtra(singleParam[1], Long.parseLong(singleParam[2]));
|
||||||
|
}
|
||||||
|
else if (singleParam[0].equals("short"))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
|
intent.putExtra(singleParam[1], Short.parseShort(singleParam[2]));
|
||||||
|
}
|
||||||
|
else if (singleParam[0].equals("Uri"))
|
||||||
|
{
|
||||||
|
if (singleParam[1].equalsIgnoreCase("IntentData"))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with value " + singleParam[2] + " as standard data parameter.", 3);
|
||||||
|
intent.setData(Uri.parse(singleParam[2]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
|
intent.putExtra(singleParam[1], Uri.parse(singleParam[2]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (singleParam[0].equals("String"))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
|
intent.putExtra(singleParam[1], singleParam[2]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Miscellaneous.logEvent("w", "StartOtherApp", "Unknown type of parameter " + singleParam[0] + " found. Name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
|
|
||||||
public static void waitBeforeNextAction(Long waitTime)
|
public static void waitBeforeNextAction(Long waitTime)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "waitBeforeNextAction", "waitBeforeNextAction for " + String.valueOf(waitTime) + " milliseconds.", 4);
|
Miscellaneous.logEvent("i", "waitBeforeNextAction", "waitBeforeNextAction for " + String.valueOf(waitTime) + " milliseconds.", 4);
|
||||||
|
Loading…
Reference in New Issue
Block a user