oasisfeng / island

Island for Android
https://play.google.com/store/apps/details?id=com.oasisfeng.island
Apache License 2.0
2.47k stars 193 forks source link

How to launch an app on the island from shell script or an action? #507

Closed kazink closed 2 weeks ago

kazink commented 3 months ago

Hi, I wanted to create a home screen shortcut to easy launch a particular app on an island, but for some reason the shortcut does not work with the launcher app I am using (Lightning Launcher). I'm getting the message 'shortcut disabled'. When I'm trying to add a shortcut manually from the launcher, the Island app is not among the shortcuts list. I tried to work this around by creating a macro to run the shortcut in Macrodroid, and then run that macro from the launcher icon, but I'm unable to create the macro either (same as before, the Island app is not on the shortcuts list). The launcher app can run a script by an icon, so I tried to create a script to run the app, but I failed too. I searched in the internet on how to run an app from a shell script, and I can run the Island app by calling "am start -n com.oasisfeng.island/.MainActivity", but I could not find a way to run specific app from an island this way. Can anyone help me please?

kazink commented 2 weeks ago

If anyone has the same problem, I couldn't find a solution, but I found a workaround. Unfortunately it requires root.

The command that needs to be run is su -c "am start --user 10 -n your.app.package.name/.your.app.acitivity". Example for SwiftBackup app: su -c "am start --user 10 -n org.swiftapps.swiftbackup/.intro.IntroActivity".

There should be a way to do that without root, because Island itself does not require root to launch an app (but launching an app as another user does), but nothing I tried worked. The command that should be working is: am start -a com.oasisfeng.island.action.LAUNCH_APP -d "app://10@org.swiftapps.swiftbackup" -n com.oasisfeng.island/.shortcut.IslandAppShortcut$ShortcutLauncher but the $ in the activity name gets stripped from the command for some reason.

If anyone has an idea how to make the non-root command work, please share.

kazink commented 2 weeks ago

I have the solution! I'm not the one who have come up with it though. TrianguloY from Lightning Launcher project is.

It looks like the double quotes were the problem. The command that works (without root) is this: am start -a com.oasisfeng.island.action.LAUNCH_APP -d "app://10@org.swiftapps.swiftbackup" -n 'com.oasisfeng.island/.shortcut.IslandAppShortcut$ShortcutLauncher' The good thing is that you don't even have to know the default activity of the target app. Just replace the org.switftapps.swiftbackup part with the package name of your app, and it should work.