How to "warm start" a deep link visit through adb - android

I am writing a service that opens deep links to Android apps through adb like so:
adb shell am start -W -a android.intent.action.VIEW -d http://www.example.com/deeplinktest com.example.mjohnst.deeplinktest
The above command works correctly:
Starting: Intent { act=android.intent.action.VIEW dat=http://www.example.com/... pkg=com.example.mjohnst.deeplinktest }
Status: ok
Activity: com.example.mjohnst.deeplinktest/.MainActivity
ThisTime: 606
TotalTime: 606
WaitTime: 731
Complete
What I want to do, is have the app already open/warm to any view, and still be able to visit the deep link.
If I have the app open on the emulator and try this, I get this warning:
Warning: Activity not started, its current task has been brought to the front
and the deep link is not visited (the current, non-linked view of the app is brought to the foreground).
Is there any way for me to visit a deep link on an already open app through adb or another interface?
EDIT: I know that there's a -s flag to kill the app before visiting, but this is not what I want. I would like the warm start to provide a performance gain

I discovered that if you start the app via a non-deeplink activity, deep linking "warm" will work.
Used this adb command to start the app:
shell am start -a android.intent.action.VIEW -n {packageName}/{activityName}

Related

android osmand api with am commands

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.

Microsoft Teams - How to launch MS Teams from Android Intent

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.

How to get extras of currently running activity through ADB

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

log into Facebook app using am start commands/ADB shell

I would like to log into the Facebook app from an android shell using am start commands.
am start -n com.facebook.katana/.LoginActivity
That command brings up the facebook login screen. But how do I fill out the email and password fields and submit it as a one line command from android shell?
I've tried the following....
am start -n com.facebook.katana/.LoginActivity -e email my#email.com -e password mypassword
To no avail, I probably don't understand the usage of extras correctly though.
Additionally, If i'm already logged in these commands work perfectly
am start -a android.intent.action.VIEW -d fb://notifications
am start -a android.intent.action.VIEW -d fb://messages
am start -a android.intent.action.VIEW -d fb://events
But I would like to allow multiple people to access their Facebook accounts using my process.
I don't think you can log in by passing username/pw extras to the Fb LoginActivity.
Take a look at the source code for the LoginActivity, it does not handle extra parameters passed to it for authentication.
https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/LoginActivity.java
The Fb docs do not document the behavior you are asking about either.
https://developers.facebook.com/docs/reference/android/3.0/LoginActivity/

Accept 'Force Close' dialog via ADB shell

I'm trying to figure out how (or if it's possible) to accept the 'Force Close' dialog via the adb shell when an Android app crashes with a hard error (specifically out_of_memory). I'm hoping to basically loop an app with a bash script, so when it crashes I want to start it running again. The missing step here is that I can't simulate pressing the 'Force Close' button that shows up in the middle of the dialog.
At the same time, the process doesn't seem to actually be running (trying to kill the PID doesn't work), so it's a bit of a weird situation because it seems to have already stopped, but launching it again (via adb shell am ...) just gives me 'current task has been brought to the front'.
Any thoughts would be appreciated!
+1 to DarkXphenomenon for the UncaughtExceptionHandler.
However to kill the process you should use am:
am force-stop: force stop everything associated with <PACKAGE>.
am kill: Kill all processes associated with <PACKAGE>. Only kills.
processes that are safe to kill -- that is, will not impact the user
experience.
for example:
adb shell am force-stop <YOUR.PACKAGE.NAME>
If it is your own app, you can add an UncaughtExceptionHandler and not show the force close dialog. If not, the following might work.
You can also kill the process from adb. (Credit)
adb shell kill $(adb shell ps | grep YOUR.PACKAGE.NAME | awk '{ print $2 }')
After that, you can use adb shell am ... to respawn the process.

Categories

Resources