Headless browser on android supporting websockets? - java

Well I'm working on a project which requires me to do a couple of automated things on a website. Its all working good. I've setup WebView and binded JS interface with Java on android to communicate with it.
It works great. But it is really ugly and painful. Also, I'm making WebView full screen and invisible in a service (I need to do that in background). The reason is that the project I'm doing uses websocket to make a request. So I cannot simply GET/POST with Java.
Moreover, the javascript used by the website is too complicated to deobfuscate and scractch out the API used by websocket to communicate (it just shows Binary OPCode 2 in Frames tab in chrome debugger)
So what I'm getting to is, is there any easy way to go headless on android which supports websockets?

Related

How to make a mobile app using HTML CSS and JS?

I am planning to develop a mobile app using HTML CSS and javascript.i plan on storing data in a local file instead of a database.how can I develop this? any ideas? The app will run in the browser of the mobile device. (this eliminates login)
The concept of the project is good.ive also designed the UI.
I think you're talking about making a website with a javascript app in it. Mobile apps are made with swift for IOS and android apps are made in java or c++.
There are programs that will take your website and put it inside an application container (mostly for android) but these programs are not recommended.
I would recommend learning swift or Java or c++ and make an app or using your html/css/javascript knowledge to make a web application.

How to create a desktop app for the existing web application?

Well, I've tried to do some researches before creating a question but only a little has been found.
Basically, I have got a Spring-based web application. Apparently, you can navigate through web application using HTTP requests and URLs. If you want to edit a user you do a GET request /users/edit/{id} and a new page appears. Then you make some changes to the user and do a POST request /users/edit/{id} and let's say the main page appears.
So, now I need to create a desktop application which can do the same things.
Do I need to rewrite the whole app to port it on the desktop? Is it possible somehow to do sort of HTTP requests from the desktop app to the server, then get a response and process it? Or perhaps there is a proper way to do it?
I feel like it's a big topic but I only need you to point me in the right direction as I'm lacking experience in creating both desktop and web applications together (I'd say, I have never ported app from web to desktop and vice verse).
Earlier I created a few apps using JavaFX and I want to use it again as my GUI platform for the desktop app.
You can go for a solution like, Electron.
It's a framework for creating native applications with web technologies like JavaScript, HTML, and CSS. It uses Chromium and Node.js. You can develop your desktop GUI applications using front and back end components originally developed for your web application.
I'm just pointing you a way. You can look in to this solution and it's also open-source.
If you were about to develop the frontend from scratch I'd recommend you to use something like Ionic Framework where in the latest beta 4 allows you to write once run everywhere (web, PWA, desktop with Electron, and build native build for iOS and Android).
Basically Ionic is an Angular 7 library/superset that allows you to create mobile apps based on a webview. This webview can be embedded and run on any device in a native way.
Even though the same codebase can be run on multiple devices you can customise the look and feel on each platform and access through Cordova, Electron or Capacitor the native device capabilities and hardware.
If you don't want to rewrite the web client, you can use any desktop framework with the preferred language you want. Any modern language/framework will allow you to make HTTP requests against your backend and get the data through your API.
Honestly, nowadays I'd day that JavaFX is not the best option out there and I'd recommend you to go through the web-based approach.
Good luck!

What is the alternatives for Java Applet to launch client programs using Chrome browsers?

I am working in a web application using ASP.net and C#.
My target is to check on a desktop application on the client machine .. If it was exist then I should launch it. Else if it wasn't exist, we should download, install and then launch it.
I could develop this module using Java Applet but unfortunately, Google decided to disable NPAPI in September 2015, So the applet will not working on Chrome.
My question is about the Applet alternatives to help me implementing the above scenario ?
The only (semi) viable option as far as I can see, is to offer the Chrome user a link to a JNLP file for a desktop application. Then when/if the JWS desktop application starts, have it report back to the server 'loaded OK' and then 'target app. installed/not installed'.
On your server, have a time out for waiting on the client to report back. If it passes that time, presume the client machine does not support Java at all and the user is checking some web service to try and figure out what app. opens a JNLP!
After searching about the most suitable way to achieve my goal, I think using custom protocols will be a nice solution to access my client applications from the web page.
This solution is used by many companies such as Microsoft (using mailto: to open Outlook application) and Apple (using itms: to open iTunes application).
The following link is a very good link which talk about a custom protocols:
https://support.shotgunsoftware.com/entries/86754-How-to-launch-external-applications-using-custom-protocols-rock-instead-of-http-
Once Google Chrome was the first to announce that they won’t be supporting NPAPI anymore, they were also the first to provide a new architecture in order to rewrite your code to work on their browser. You can take a look on Native Messaging, which “can exchange messages with native applications using an API that is similar to the other message passing APIs”. The problem is that this approach only works on Chrome, is not something that you can adapt to other browsers.
A more useful approach is FireBreath, a browser plugin in a post NPAPI world. Check the words below from one buddy of the project:
“FireBreath 2 will allow you to write a plugin that works in NPAPI, ActiveX, or through Native Messaging; it’s getting close to ready to go into beta. It doesn’t have any kind of real drawing support, but would work for what you describe. The install process is a bit of a pain, but it works. The FireWyrm protocol that the native messaging component uses could be used with any connection that allows passing text data; it should be possible to make it work with js-ctypes on firefox or plausibly WEB-RTC or even CORS AJAX in some way. For now the only thing we needed to solve was Chrome, but we did it in a way that should be pretty portable to other technologies.”

Can I make an HTML5 game for Android?

Ok to be more specific... can I program an android app in Java that has something like a web view to which I can point to local files on the phone?
I'm thinking about making an android game and i'm wondering if it can be done with a little HTML5 and Javascript that is locally stored on the phone. I heard something about a web view in Java and that is why I am wondering if it could work.
Is this even possible?
As the other answers might be correct, there is a much simpler way:
If you know html5 programming, you can do a simple Android app that has one Activity containing one WebView. In that webview you load your index.html and there you go. You can basically do anything you would do on a normal web app.
PhoneGap and Appcelerator are for cross platform development and they provide access to the hardware (vibration, sensors etc) and they give you the possibility to build the native UI with html and javascript. For a pure WebApp they are not the correct frameworks/tools I think. I might be mistaken, but a WebGL Benchmark I wrote for PCs worked out of the box in the android browser and I justed used html5 and JavaScript.
Your answer is yes, your solution is phoneGap
http://phonegap.com/
yes definitely,
check out appcelerator.com, phonegap.com etc
u can probably go to google "cross platform mobile development"
there's a few neat html javascript frameworks

Desktop & mobile web application with offline handling

I am evaluating different approaches to building a web based application which handles offline disconnection gracefully. The intention is to create a desktop/tablet UI and a separate mobile UI for the app, backend functionality would be implemented in Java. In principle, the components are mostly there; HTML5 offline seems to have wide support and works well while Web SQL has enough support (Chrome, Opera, iPhone & Android) that we could work with it for offline storage.
As regards creating the UI, it would be nice to use some of the nice JSF libraries out there (Primefaces looks quite nice for example although I've never used it in production). So far, I can't think of any way (and I can't see anything mentioned) of using either HTML5 offline or web SQL in a JSF app. Has this been tried? Is there any methodology/framework that might help here?
I'm also not averse to using client side frameworks. I was very impressed by Dojo for example but then found that it didn't render well on Android with webkit so that ruled it out of use for the tablet scenario. I can probably make jQuery work but I find it to be very fragmented (for example, getting an accordion to handle resizing inside a layout frame just put me off). Finally, I looked at GWT; I wasn't keen on the complexity of getting offline to work and the support for web sql seemed to be a work in progress (no slight intended to the developers, it just seemed to be at an early stage).
So, given the requirement for a web app that runs on desktop/tablet (android) and also on mobile (Android & iPhone) and which handles offline, how would you approach things?
Thanks,
Phil

Categories

Resources