Launching apps in Android isn't straightforward. You'll have to use am start
combined with certain <PARAMS>
to launch the app or a particular section of it.
From the comments, it seems that you may want to launch the text file using ES Note Editor. In that case, first identify the activity responsible for the edit window you see when the file is opened in the editor using GUI.
Note: Tested the solution on Android 4.2, 4.4 and 5.0.
Instructions
- Open the file manually in the editor using GUI, and make sure that it stays active on the screen.
Connect your phone into PC in debugging mode, setup ADB on PC, and enter into PC's terminal/cmd the commands:
adb shell
su
dumpsys activity | grep mFocusedActivity
The output may look like:
mFocusedActivity: ActivityRecord{42839028 u0 com.estrongs.android.pop/.app.editor.PopNoteEditor}
The relevant info (activity) is .app.editor.PopNoteEditor
and package name is com.estrongs.android.pop
. You may use the command dumpsys activity
to see some more useful stuff.
That's just for brief understanding. Keep the whole string (com.estrongs.android.pop/.app.editor.PopNoteEditor
) ready to be used.
You may close the editor on Android. Open your favorite terminal app in Android and enter:
su
am start -n <PACKAGE_NAME/ACTIVITY> -d <FILEPATH> --activity-clear-task
-n
will allow to launch the app's mentioned component.
<PACKAGE_NAME/ACTIVITY>
is the string we noted in step 2. For ES Note Editor it would be com.estrongs.android.pop/.app.editor.PopNoteEditor
.
-d
is to allow data to be passed to the app's activity.
<FILEPATH>
is the location of the text file you want to open.
--activity-clear-task
will make sure that the activity is not launched from "Recents" but from scratch.
(Enter am start
to dive deeper into interesting stuff.)
In my case, the final query for file aero.txt
under /sdcard/airdroid/
looked like:
am start -n com.estrongs.android.pop/.app.editor.PopNoteEditor -d file:///sdcard/airdroid/aero.txt --activity-clear-task
The file opened successfully.
I use QuickEdit Text Editor as default text editor and the relevant query looked like:
am start -n com.rhmsoft.edit/.activity.MainActivity -d file:///sdcard/airdroid/nmon.txt --activity-clear-task
Have fun!
nano
orvi
are usually available on *nix based systems. I prefer nano because it is a bit cleaner imho.