termux-api icon indicating copy to clipboard operation
termux-api copied to clipboard

Intent launcher and getting results from it

Open TheSandBoxMKG opened this issue 2 years ago • 3 comments

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.

TheSandBoxMKG avatar Dec 04 '22 14:12 TheSandBoxMKG

Isn't this is same as what utility am does?

sylirre avatar Dec 04 '22 15:12 sylirre

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

agnostic-apollo avatar Dec 04 '22 16:12 agnostic-apollo

I'd appreciate this. My use case is being able to start a QR scanner from my scripts.

easrng avatar Sep 05 '23 22:09 easrng