- Published on
Android Replace Google Webview Search with Firefox
- Authors
- Name
- Yair Mark
- @yairmark
I have started to try use Firefox as my go to browser on Android. One of the biggest issues I ran into with this transition is that with Nova Launcher launcher I have a swipe gesture defined which lets me quickly search the web for something.
Nova does have a section where you can specify an app action to attach to a gesture. But unfortunately there is no "New Tab" or "Add to Firefox" action for Firefox. I can easily make Nova open Firefox by using the app option for my swipe action but then I still need to open a new tab and search from there. Tasker exposes an action called "task shortcut" which seems perfectly suited for what we need.
Tasker is often very well suited for something like this but it can sometimes require a bit of digging. Tasker has a "Send Intent" action which lets you trigger an intent. Using this I can probably do what I need to do the problem now is working out what this intent is and what other data gets passed with it. To work out what intents an app has there are a number of things I tried:
Option 1: Download the App's APK and look at its manifest
- Download the apps apk to a pc from this website
- Unzip the apk (it is basically just a zip file with a certain folder structure)
- Search inside the AndroidManifest.xml file for all intent filters
The problem with this approach is often the manifest has large chunks of binary data making it hard to read.
Option 2: Use the Inspeckage Xposed Module to Inspect the app on your phone
- Install the Inspeckage Xposed module
- Restart your phone
- Open up Inspeckage
- Turn off "Only user app"
- Under "choose target" choose the app you want to inspect
- Push the "Launch App" button, this should launch the target app
- You can then view an app's details in one of two ways:
- On a computer that your phone is connected to:
- Connect your phone to a computer using the USB cable
- In a terminal run
adb forward tcp:8008 tcp:8008
- On the same computer navigate to the IP and port displayed in the app
- On your phone: simply navigate to: http://localhost:8008
- On a computer that your phone is connected to:
- You should now see an interface similar to the below screenshot
The source code for this module can be found here. This approach made it easy for me to find all possible intents and activities for an app but did not show me what data needs to be passed with these.
Option 3: Use adb logcat
I came across this answer on Stackoverflow which explained how to see what intents were being passed around in real time together with the data passed around. The steps I followed were:
- Connect phone to computer
- Get adb logs and grep out intents:
adb logcat | fgrep -i intent
- Trigger the intent on your phone
- Inspect logs to find the details of the intent
This output:
09-30 00:53:08.511 1635 2034 I ActivityManager: START u0 {act=android.intent.action.SEND typ=text/plain flg=0xb080001 cmp=org.mozilla.firefox/org.mozilla.gecko.overlays.ui.ShareDialog clip={text/uri-list U:content://com.android.chrome.FileProvider/BlockedFile_3027446111187} (has extras)} from uid 10121
09-30 00:53:08.669 17794 17794 I Xposed : Inspeckage_IPC:startService: Intent { act=org.mozilla.gecko.overlays.ACTION_PREPARE_SHARE cmp=org.mozilla.firefox/org.mozilla.gecko.overlays.service.OverlayActionService }
09-30 00:53:13.062 17794 17794 I Xposed : Inspeckage_IPC:startActivity: Intent { act=android.intent.action.VIEW dat=https://www.popsci.com/... cmp=org.mozilla.firefox/org.mozilla.gecko.BrowserApp (has extras) }
09-30 00:53:13.063 1635 5195 I ActivityManager: START u0 {act=android.intent.action.VIEW dat=https://www.popsci.com/... cmp=org.mozilla.firefox/org.mozilla.gecko.BrowserApp (has extras)} from uid 10118
09-30 00:53:13.281 17794 17794 I Xposed : Inspeckage_IPC:startService: Intent { act=org.mozilla.firefox.DLC.STUDY cmp=org.mozilla.firefox/org.mozilla.gecko.dlc.DownloadContentService }
...
Line 3 in the above is the one we need:
09-30 00:53:13.062 17794 17794 I Xposed : Inspeckage_IPC:startActivity: Intent { act=android.intent.action.VIEW dat=https://www.popsci.com/... cmp=org.mozilla.firefox/org.mozilla.gecko.BrowserApp (has extras) }
Putting it all together
Using this information I went to Tasker and then:
- created a task called "OpenTabInFirefox"
- added a "Send Intent" action with:
- Action: android.intent.action.VIEW
- Cat: Default
- Mime Type:
- Data:
- Extra:
- Extra:
- Extra:
- Package: org.mozilla.firefox
- Class: org.mozilla.gecko.BrowserApp
- Target: Activity
- assigned the task an icon
- Tasker will not let you assign it to a task shortcut otherwise
- opened Nova launcher's settings
- went to "Gestures & inputs"
- chose a desired gesture (for example "Swipe up") and went to "SHORTCUTS"
- chose the "Task Shortcut"
- chose the task created earlier and pushed back
Now when you use your chosen gesture Firefox is opened with a new tab. The only thing I still am trying to workout is how to get Tasker to set the cursor in the address bar and open up the keyboard other than that this does exactly what I wanted it to do.