From f24c9f99dc020d1844307b4f6d54be94f848ad76 Mon Sep 17 00:00:00 2001 From: jens Date: Sun, 5 Nov 2023 16:20:48 +0100 Subject: [PATCH] startService() experiments --- app/src/main/java/com/jens/automation2/Actions.java | 12 +++++++++++- .../ActivityManageActionStartActivity.java | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/jens/automation2/Actions.java b/app/src/main/java/com/jens/automation2/Actions.java index 5f56a24..2317c7d 100644 --- a/app/src/main/java/com/jens/automation2/Actions.java +++ b/app/src/main/java/com/jens/automation2/Actions.java @@ -10,6 +10,7 @@ import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; import android.content.ActivityNotFoundException; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.media.AudioManager; @@ -1080,6 +1081,14 @@ public class Actions if (!params[0].equals(dummyPackageString)) externalActivityIntent.setPackage(params[0]); + externalActivityIntent.setPackage("net.christianbeier.droidvnc_ng"); + + if (params[2].equals(ActivityManageActionStartActivity.startByServiceString)) + { + //externalActivityIntent.setComponent(new ComponentName(params[0], params[1])); + externalActivityIntent.setComponent(new ComponentName("net.christianbeier.droidvnc_ng", ".MainService")); + } + externalActivityIntent.setAction(params[1]); } @@ -1091,7 +1100,8 @@ public class Actions if (params[2].equals(ActivityManageActionStartActivity.startByActivityString)) automationServerRef.startActivity(externalActivityIntent); if (params[2].equals(ActivityManageActionStartActivity.startByServiceString)) - automationServerRef.startService(externalActivityIntent); + //automationServerRef.startService(externalActivityIntent); + automationServerRef.startForegroundService(externalActivityIntent); else automationServerRef.sendBroadcast(externalActivityIntent); } diff --git a/app/src/main/java/com/jens/automation2/ActivityManageActionStartActivity.java b/app/src/main/java/com/jens/automation2/ActivityManageActionStartActivity.java index 93b8ae1..eb4b670 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageActionStartActivity.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageActionStartActivity.java @@ -90,7 +90,6 @@ public class ActivityManageActionStartActivity extends Activity intentTypeSpinnerAdapter.notifyDataSetChanged(); intentPairAdapter = new ArrayAdapter(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList); - bSelectApp.setOnClickListener(new OnClickListener() { @Override