Sunday, March 31, 2019

ssh - how to run a specific app's action via terminal?


I need to run my android app from a remote computer via SSH, but I'm not a command-line expert, so I would like to know: how to run a specific action of an app? (not just open it) Which implies: how to KNOW the exact sintax of possible actions of an app?


eg: I want to start a audio-recording app on my phone from my computer, AND start recording from remote. Is it possible?


Thanks, Andrea



Answer



Use this:


am start -a android.intent.action.MAIN -n /

To control an app, you'll have to put correct values of and in the command. For example, you can use com.google.gmail/com.google.gmail.check_mail (Hypothetical names) as last part of command.



Obtaining package name of an app is easy, but obtaining class name of action isn't. There are two problems:




  1. Many app developers keep class info private.




  2. Not all developers do smart modular programming. Its good habit to divide an app in multiple classes which could be triggered by intents, but not all developers are smart.




Solution of 1st problem: Decompile the app using apktool and see all info. There are also other ways, but this one is always-working method (unless app is based on NDK instead of SDK).



Solution of 2nd problem: Nothing.


Don't worry, most of popular apps follow best programming practice and they provide Public API from which you can get class info.


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...