Launching on android WEBAPP with ADB - javascript

Is there a method to launch a web app using adb?
The web app is created using manifest.json and save on android using chrome browser.
I've tried to get the package name of the web application using adb shell pm list packages but nothing seems to match.
I want to launch my web app this way adb shell am start -n com.package.name/com.package.name.ActivityName
I've also tried this way adb shell am start -a android.intent.action.VIEW -d "url". This works but it is not what I am looking for.

Assuming you are coming from Javascript world (as you could have done this by looking at adb logs), this should be what you are looking for
adb shell am start -a com.google.android.apps.chrome.webapps.WebappManager.ACTION_START_WEBAPP -n com.android.chrome/org.chromium.chrome.browser.webapps.WebappLauncherActivity --es "org.chromium.chrome.browser.webapp_url" "{your_url}" --es "org.chromium.chrome.browser.webapp_mac" "{webapp_mac}"
Note that this url has to match the url/url-ending you have mentioned in the start_url that you have mentioned in the manifest.json of yours, else it will just open it as another chrome tab.
Another caveat here is you have to pass web app mac validation check, which is done by the core android class mentioned here - WebappAuthenticator
Chrome does not keep a store of valid URLs for installed web apps
(because it cannot know when any have been uninstalled). Therefore,
upon installation, it tells the Launcher a message authentication code
(MAC) along with the URL for the web app, and then Chrome can verify
the MAC when starting e.g. {#link #FullScreenActivity}. Chrome can
thus distinguish between legitimate, installed web apps and arbitrary
other URLs.
I gave it a shot to open one of the webapps I own. I gave up after a bit, getting lost in the cryptic algos. Maybe you will have some luck with it. All the best!!!

Related

How to debug JavaScript errors when running a Cordova App on Android TV

I have written a Javascript script which I bundled into an Android app using Cordova.
The code is written in ES6 and is transpiled into ES5 using Babel and Webpack.
The app is intended to run on a simple TV, so I am using MK809 Android dongle to transform a TV into an Android-based TV. Then I install the new app and try to run it.
The problem is that the app terminates immediately (most probably due to some ES5 errors as the transpilation is probaby not complete or correct).
Is there a way this can be debugged?
When I run it on my computer's Chome, everything works perfectly as it has full ES6 support. The app also runs perfectly on my Android phone as it uses a modern browser which supports ES6.
I am not a FE guy, so my knowledge is a bit limited.
Can anyone suggest the best way to debug this? How can I run a local copy of a brower with ES6 disabled so that I could easily spot the problem?
Thank you
The only I see you could achieve this would be to root this Android dongle and install something like ADBWifi so you can debug it through Chrome/ADB over your local network. This is what I do for ChromeOS devices, not too sure if it's doable with your device...
I found out that using a service like errlog.io gives me what I need.
JavaScript errors get captured and sent to the their service and then are accessible on the dashboard
see: Get Started with Remote Debugging Android Devices
the MK809 dongle has an USB port and it would need to have USB debugging enabled.
then go to chrome://inspect on the computer's Chrome, in order to access the debugger.
logging and debugging is something very else; that dongle actually is a Rockchip RK3066.

electron + simplewebrtc workable?

Does anyone use electron + simplewebrtc successfully?
I used simplewebrtc to build a web app. It works fine in browsers.
When I migrated it into electron, something weird happened.
At first I used two copies of my electron app to make them connect each other, but failed.
Then, I made a web browser version and a electron version connect each other.
First, only when the electron version joined the room first, and then made the web version join the room, they can connect each other. otherwise, if the order changes, they cannot get the event peer.pc.iceConnectionState to "connected".
Second, even if them are connected, data channel only works on one way. Only web version can send message to electron version. If I try to let electron version send a message to web version, nothing happened.
During the whole time, no any error was thrown.
Thank you in advance.
simplewebrtc 2.2.3 - 3.0.1
Electron: 1.7.6
Web browsers: Chrome 62, Opera 49, Chromium 58

Using Realm and Remote Debugging fails on android

Importing and using Realm on react native works fine for iOS. Android also works in terms of functionality, however, when using remote debugging on chrome the following error yields.
I've looked around almost everywhere and nobody seems to have a clear cut answer for this. Anyone here that has managed to get out of this pit? Remote debugging is quite essential as the app is dealing with rather complex objects and using react-native log-ios is a little hard on the workflow.
Thanks all.
Easy fix is to goto node_modules/realm/lib/browser/rpc.js and replace line 216 with let url = 'http://127.0.0.1:8083/' + command;
You're running into known issues w/ android remote debugging, but they're being worked on. You can track progress here: https://github.com/realm/realm-js/issues/491
I've met this problem when I've used react native with realm database. I think you need manually port reverse and forward to avoid conflict port.When you enable debug mode, please open command line and follow below command:
`adb reverse tcp:8081 tcp:8081`
`adb forward tcp:8082 tcp:8082`
Then, you can reload and go into debug mode.
Cheer!
if answer from #johnny didn't work, when you type the commands
adb reverse tcp:8081 tcp:8081
adb forward tcp:8082 tcp:8082
and you get the following message
adb server is out of date. killing...
* daemon started successfully *
that means that the adb command you are using in command line, and the adb tool used by the emulator are different.
you can confirm that by checking the location of adb (here I have two different tools in /usr/bin and /home, which are not symlinks as verified after)
42:~/pathToMyApp$ whereis adb
adb: /usr/bin/adb /home/42/Android/Sdk/platform-tools/adb /usr/share/man/man1/adb.1.gz
I tried with the full path on both tools, and I discovered the emulator was using the adb tool in /home/...
So to make it work I now type
/home/42/Android/Sdk/platform-tools/adb reverse tcp:8081 tcp:8081;
/home/42/Android/Sdk/platform-tools/adb forward tcp:8082 tcp:8082
I was able to resolve this issue in my pixel_3XL simulator android API level : 29
reset the path for platform-tools
changed my PATH to platform-tools
$ export PATH=${PATH}:/root/Android/Sdk/platform-tools
$ adb kill-server
$ adb root #will give root access for adb
$ adb forward tcp:8082 tcp:8082
$ adb reverse tcp:8081 tcp:8081
$ react-native run-android #restart the server with a debugger enabled
voila, it worked in my machine... good luck.
additionaly try changing the ip to 127.0.0.1 and port manually in app's Developer menu -> Dev settings -> Debug server host & port
Doing this worked for me
on terminal:
adb reverse tcp:8081 tcp:8081
adb forward tcp:8082 tcp:8082
adb forward tcp:8083 tcp:8083

Check if a non app store application is installed in windows 10 machine

I have installed a windows desktop application(not from app store).
How can I check if this app is installed from other application using javascript?
Is there any plugin available for Windows application like cordova AppAvailability for Android/iOS?
You can use WMI (Windows Management Instrumentation) to generate a list of installed apps via the wmic command-line tool, and go over this list to find the app you're searching.
If you're running NodeJS, you can use the node-cmd package to execute the sequence of commands in the link above, and capture the string output so you can parse later.

How can I tell if my Cordova application is running on a simulator or real device?

I'd like to be talk to a different server when running in an emulator / simulator.
It looks like device.platform used to mention the simulator, but know it just says "iOS". The user-agent doesn't seem to differentiate either.
Ideally the solution would work for all platforms, but I'll take Android and iOS, or in fact anything helpful!
For iOS I just check the model - if matches /x86/ then it's the simulator (until Apple release an Intel iOS device).
function isRunningInSimulator(device) {
// Only valid after deviceReady
return device && device.model.match(/x86/);
}
In the most recent version of the Device plugin (https://www.npmjs.com/package/cordova-plugin-device), there is now a isVirtual property that represents this.
I don't know if it is possible to detect. One "workaround" is use a task manager (grunt, gulp, whatever) to copy configuration files from on folder to other. Then instead of running "cordova run android" (example) at the command line, you would run a task that copies the config file(s) from one specific folder (i.e.: development or production) an the application read the copied file.
You can take a look here http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ at the section "Replace Text Depending on Environment"

Categories