on my android phone I want to control osmand using the osmand api. To send the intents I want to use the am command available in adb shell or termux.
I am able to start osmand with am start net.osmand.plus/net.osmand.plus.activities.MapActivity
In my first test I just want to stop the navigation (command: STOP_NAVIGATION).
First I tried am start -a stop_navigation -n net.osmand.plus/net.osmand.plus.activities.MapActivity. The result was Starting: Intent { act=stop_navigation cmp=net.osmand.plus/.activities.MapActivity } Warning: Activity not started, its current task has been brought to the front, which makes sense.
Then I tested some broadcast commands, e.g.:
am broadcast -a stop_navigation -n net.osmand.plus/net.osmand.plus.activities.MapActivity
am broadcast osmand.api://stop_navigation
I also tested it with capital letters. But no command was successful.
Is there someone which has more experiences with android intents and / or osmand api and can help me how to create a working command?
Thanks in advance!
I already found the solution, it was simpler than expected. Maybe I can help someone with the solution:
The command am start osmand.api://pause_navigation is enough.
BTW:
termux-open osmand.api://pause_navigation does also work.
Related
I'm looking to launch an intent to open the Microsoft Teams main activity from my app. I would assume it would be something like com.microsoft.teams.MainActivity but this does not seem to launch. Trying to open via URI of msteams://teams.microsoft.com takes me to the browser instead of the app.
Is this functionality possible?
Edit: Using adb gave me the following, however this also does not seem to work.
C:\Users\Redacted>adb shell dumpsys window | find "mCurrentFocus"
mCurrentFocus=Window{91c21a9 u0 com.microsoft.teams/com.microsoft.skype.teams.views.activities.MainActivity}
As Posted by #Nicolas - Use com.microsoft.skype.teams.views.activities.MainActivity.
I was able to launch the MS Teams application using command:
adb shell am start com.microsoft.teams/com.microsoft.skype.teams.Launcher
So I think that you can use activity com.microsoft.skype.teams.Launcher.
Note: I'm fairly new to linux/android when it comes to using the shell and commands/scripting, so if I've given some unrelevant information, or I'm trying to do something not possible, please tell me what's not relevant and why something is not possible and explain anything else to help me become better at this.
I'm trying to make a script that stop's Orbot's Tor network automatically when I exit from the Orfox app. So far, I have most of the coding down except for the stopping part for Tor. I believe there is something I can use in a shell script that would stop the Tor network right?
Currently, my script uses the command
# am force-stop org.torproject.android
to stop the app (to stop the Tor network), but I know that can't be the only way...
I know that when I press the Start button (within the Orbot app) or open up Orfox, it starts up the Tor network... When using
# ps | grep torproject
2 times (before and after starting Tor), I found that
u0_a291 11209 1 23092 15712 sys_epoll_ b68ecf18 S /data/data/org.torproject.android/app_bin/tor
shows up only when Tor is on.
I also found that after using
# ps | grep u0_a291
(the same way as the last command) that two shell's are started:
u0_a291 11150 8783 3780 1336 pipe_wait b6d9d0ac S sh
u0_a291 11212 8783 3780 1340 pipe_wait b6dec0ac S sh
only when tor is on.
I'm assuming some of the commands running through one or both of the shell's will give me a hint as to what commands I may need in order to stop the tor network in my script, but I have no idea how to view them or if I can. Is there a way to view them, or maybe I'm going about trying to find out how to stop Tor in the wrong way? So help me out guys, please.
I figured out what it was after all, and I didn't need any of the information that I provided... facepalm
I found out what the service and intent action I needed by looking at the base.apk (in /data/app/org.torproject.android) as an archive. I looked at the AndroidManifest.xml like a text file and found the service and it's intent action to be
.service.TorService
org.torproject.android.intent.action.Start
I concluded my script by using this to stop the tor service... I bet this might help someone else out in the future.
# am stopservice -n org.torproject.android/.service.TorService -a org.torproject.android.intent.action.START
I have a question about using ADB.
I know that this command:
adb shell dumpsys activity
can show me all the activities that are currently running on the device.
But I notice that sometimes, the intents appear like this:
Intent { ...some_intent/activity_name.... (has extras) }
I know that extras mean that the activity has been started with some sort of parameters passed to it (I may be wrong here, please correct me if I am).
So my question is, how can I get the extras of the intent/activity through ADB ?
The reason I need this is because I'm trying to launch an apk (that is installed on the phone) through ADB command, something like:
adb shell "su -c 'am start -n com.package.name/.ActivityName'"
That works and bring up the application. The application has a start screen (say we call it HomeActivity) and you have to click a button and make some selections (say SelectionActivity) and it will go to another screen (say ActionActivity). I want to be able to launch the apk and make it go straight to ActionActivity.
The application will crash if I try to launch the ActionActivity with am start command, I'm assuming this is because it requires parameters from the SelectionActivity screen.
This is why I'm trying to see what are the "extras" or parameters that the ActionActivity screen actually gets, so that I can do something like:
adb shell "su -c 'am start -n com.package.name/.ActionActivity -e param1 val1 -e param2 val2'"
Hope my question is clear.
Please correct me if I'm making a mistake somewhere.
Thanks in advance!
If I am understanding correctly, your target is to start the 'action' activity with correct intent but you don't know what kind of parameter information should be included, right?
The dumpsys command won't dump everything you want, so to simply achieve your target, you have 2 options (you should find one device which you can burn your own firmware into it):
Modify the dump method in AMS to print out more information
Modify the ActivityThread class source code to print out the detailed intent information
is there a simple way to stop a running application using ADB.
Szenario:
Working on App
Have a script which uploads, installs and starts App on change
Problem:
Currently running version gets killed (not shutdown), which make testing cleanup very hard. Option would be to "do cleanup in between", like after a certain time, but I would prefer to do it in the correct location (so like with the OS, as long as the App is still running, so need to save value, as soon as the OS tells me e.g. memory low or calls onDestroy, I want to save stuff)
Chris
I'm not aware of a way to do this. I was hoping there might be a way to send an intent to tell the app to exit using adb shell e.g.
adb shell am start -a [intent] -n [class]
However, I found that somebody asked this question on a Google forum but they haven't got an answer:
http://groups.google.com/group/android-platform/browse_thread/thread/3fd02d01c6c3b41a/56814e518503efd6
I am trying to test my apps using python and monkey runner.
I want to send an intent during start activity.
I tried using extras and this doesnt help.
Can some one help me with this? If possible can some one provide me a sample AndroidManifest.xml and test.py on how to do this.
Thank you all for the help
blr p sh
There are some bugs in monkeyrunner avoiding correct handling of extras. This question also mentions the case passing booleans, but it's not restricted to them.
The workaround, as monkeyrunner does not do much that invoking ADB in this cases is to use
device.shell('am start -a android.intent.action.MAIN -n my.pkg/.MyActivity -e key val')