lowellk
lowellk

Reputation: 2057

How can I provide a command line interface to my Android app?

I would like to be able to type commands on my development machine (macOS/zsh) and have them do things on my Android app. This will require custom code in my Android app. What I'm trying to do is something similar to automating certain settings, so that I don't have to navigate to the settings screen of my Android app manually. This is to help me save time while I'm developing my app.

How can I get started? I'd love to see some examples of this being done but have been having trouble finding them.

Are there any libraries that can help me with this?

Also, for bonus points, I'd love to be able to have some sort of autocomplete on my Mac command line. How might I build that?

Upvotes: 0

Views: 759

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93559

There's a few ways to do this:

1)Just write a Linux app, move it to your device, set the executable bit, and run it from adb shell (adb shell opens up a shell on an attached device with debugging enabled).

2)If you really need to access the app while its running, you can send intents to your app via the shell via adb shell am <options> This allows you to send an intent to the system. Then just write a custom Activity, Service, or BroadcastReceiver to receive that Intent and act upon it.

Upvotes: 1

Related Questions