termux-api
termux-api copied to clipboard
Intent launcher and getting results from it
Feature description
A way to launch intents and getting results from them.
Reference implementation
Have you checked if the feature is accessible through the Android API? Do you know of other open-source apps that has a similar feature as the one you want? (Provide links)
As for the launching part, it's available in all activity launcher applications including Activity Manager.
As from the getting the results parts, I don't recall of any open source app doing it specifically but the Tasker plugin IntentTask does it to pass the results to Tasker.
Isn't this is same as what utility am
does?
Currently, no support for this, but is planned for future. Activities can start other activities with startActivityForResult()
and then when target activity finishes, they get a call back in onActivityResult()
with result extras and response code, etc, similar to what happens when you request permissions from users.
am
doesn't do that, it just starts the activity and exits and it can't wait anyways since it doesn't launch from an Activity
to actually handle onActivityResult()
. ShareAPI
or a dedicated API or possibly termux-am-socket
could implement that.
https://github.com/termux/TermuxAm/blob/50f9d301811a22fc6a891b975600a21a3d152957/app/src/main/java/com/termux/termuxam/Am.java#L635
https://github.com/termux/termux-api/blob/ba2836ba60083b54dcdb6a3a926777f3f0704829/app/src/main/java/com/termux/api/apis/ShareAPI.java
I'd appreciate this. My use case is being able to start a QR scanner from my scripts.