diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 4775f5e..fdada6e 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -50,6 +50,9 @@
+
+
@@ -78,6 +81,12 @@
android:exported="false"/>
+
+
+
+
+
diff --git a/app/src/main/java/org/xbmc/kore/service/HostChooserTargetService.java b/app/src/main/java/org/xbmc/kore/service/HostChooserTargetService.java
new file mode 100644
index 0000000..aee5322
--- /dev/null
+++ b/app/src/main/java/org/xbmc/kore/service/HostChooserTargetService.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2018 Dan Pasanen. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.xbmc.kore.service;
+
+import android.annotation.TargetApi;
+import android.content.ComponentName;
+import android.content.IntentFilter;
+import android.graphics.drawable.Icon;
+import android.os.Build;
+import android.os.Bundle;
+import android.service.chooser.ChooserTarget;
+import android.service.chooser.ChooserTargetService;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xbmc.kore.host.HostInfo;
+import org.xbmc.kore.host.HostManager;
+import org.xbmc.kore.R;
+
+@TargetApi(Build.VERSION_CODES.M)
+public class HostChooserTargetService extends ChooserTargetService {
+
+ @Override
+ public List onGetChooserTargets(ComponentName targetActivityName, IntentFilter matchedFilter) {
+ final List targets = new ArrayList<>();
+ HostManager hostManager = HostManager.getInstance(this);
+
+ final Icon icon = Icon.createWithResource(this, R.mipmap.ic_launcher);
+ final float score = 0;
+ final ComponentName componentName = new ComponentName(getPackageName(), "org.xbmc.kore.ui.sections.remote.RemoteActivity");
+
+ for (HostInfo host : hostManager.getHosts()) {
+ Bundle intentExtras = new Bundle();
+ intentExtras.putInt("hostId", host.getId());
+ targets.add(new ChooserTarget(host.getName(), icon, score, componentName, intentExtras));
+ }
+
+ return targets;
+ }
+}
diff --git a/app/src/main/java/org/xbmc/kore/ui/sections/remote/RemoteActivity.java b/app/src/main/java/org/xbmc/kore/ui/sections/remote/RemoteActivity.java
index 2fdc0df..a6f841a 100644
--- a/app/src/main/java/org/xbmc/kore/ui/sections/remote/RemoteActivity.java
+++ b/app/src/main/java/org/xbmc/kore/ui/sections/remote/RemoteActivity.java
@@ -39,6 +39,7 @@ import android.widget.Toast;
import org.xbmc.kore.R;
import org.xbmc.kore.Settings;
import org.xbmc.kore.host.HostConnectionObserver;
+import org.xbmc.kore.host.HostInfo;
import org.xbmc.kore.host.HostManager;
import org.xbmc.kore.jsonrpc.method.Application;
import org.xbmc.kore.jsonrpc.method.AudioLibrary;
@@ -386,6 +387,18 @@ public class RemoteActivity extends BaseActivity
videoUrl = videoUri.toString();
}
+ // If a host was passed from the intent use it
+ int hostId = intent.getIntExtra("hostId", 0);
+ if (hostId > 0) {
+ HostManager hostManager = HostManager.getInstance(this);
+ for (HostInfo host : hostManager.getHosts()) {
+ if (host.getId() == hostId) {
+ hostManager.switchHost(host);
+ break;
+ }
+ }
+ }
+
String title = getString(R.string.app_name);
String text = getString(R.string.item_added_to_playlist);
pendingShare = getShareExecutor().submit(new OpenSharedUrl(hostManager.getConnection(), videoUrl, title, text));