StartAppChanges

This commit is contained in:
jens 2021-04-13 20:00:36 +02:00
parent 1c24af7bcb
commit 8843a97b79
2 changed files with 70 additions and 57 deletions

View File

@ -589,8 +589,10 @@ public class Actions
else
externalActivityIntent.setClassName(packageName, className);
if(Miscellaneous.doesActivityExist(externalActivityIntent, Miscellaneous.getAnyContext()))
{
// has intent values to deliver
for(int i=2; i<params.length; i++)
for (int i = 2; i < params.length; i++)
{
String[] singleParam = params[i].split("/");
@ -604,62 +606,67 @@ public class Actions
}
}*/
if(singleParam[0].equals("boolean"))
if (singleParam[0].equals("boolean"))
{
Miscellaneous.logEvent("i", "StartOtherApp" , "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
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"))
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);
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"))
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);
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"))
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]);
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"))
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);
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"))
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);
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"))
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);
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"))
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);
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"))
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);
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("String"))
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);
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);
Miscellaneous.logEvent("w", "StartOtherApp", "Unknown type of parameter " + singleParam[0] + " found. Name " + singleParam[1] + " and value " + singleParam[2], 3);
}
autoMationServerRef.startActivity(externalActivityIntent);
}
else
{
Miscellaneous.logEvent("w", "StartOtherApp", "Activity not found: " + className, 2);
}
}
catch(ActivityNotFoundException | SecurityException e)
{
Miscellaneous.logEvent("e", "StartOtherApp", autoMationServerRef.getResources().getString(R.string.errorStartingOtherActivity) + ": " + Log.getStackTraceString(e), 2);

View File

@ -7,6 +7,7 @@ import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.ContentProvider;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -1327,4 +1328,9 @@ public class Miscellaneous extends Service
Toast.makeText(context, "Request failed try again: "+ t.toString(), Toast.LENGTH_LONG).show();
}
}
public static boolean doesActivityExist(Intent intent, Context context)
{
return intent.resolveActivityInfo(context.getPackageManager(), 0) != null;
}
}