B4J Question From Chrome apps to B4J?

Martin Larsen

Active Member
Licensed User
Longtime User
Hi,

I am a Chrome app developer. Google recently announced that Chrome apps will cease to be supported from 2018 which is very, very bad news.

Chrome apps are fantastic because they allow you to create lightweight, cross platform, standalone apps that can even run offline. They use Chrome as the engine, but you can actually launch these apps without starting Chrome. And since Chrome is already installed, they have a really small footprint. And they run on Linux, Mac, Windows and ChromeOS.

So now I am looking for an alternative and my mind goes to B4J. Since I am already a big fan of B4A, this seems an obvious choice. Not least because I am actually planning a B4A (and probably B4I) version of my Chrome app TV4ever.

However, I have a couple of questions.

1. Is the requirements mostly met by end users? In other words, will users generally be able to run B4J apps right away, or will they have to install the Java runtime first?

2. I notice that B4J has a webview component. Is it possible to tap into the webview like it is in Chrome apps and for example manipulate the DOM contents and listening for events?

3. In the Showcase I see examples for Android and IOS but not desktop apps. Are there any nice examples made with B4J I could evaluate?

Thanks!

Martin
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Martin Larsen

Active Member
Licensed User
Longtime User
Thanks Erel for you quick reply. You were too quick for me in fact, since I shortly after added a question #3 :)

3. In the Showcase I see examples for Android and IOS but not desktop apps. Are there any nice examples made with B4J I could evaluate?

What happens if the user already has the JRE - will the installer use that instead of the embedded version?
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
What happens if the user already has the JRE - will the installer use that instead of the embedded version?
No, it will use the version included in the packager

In the Showcase I see examples for Android and IOS but not desktop apps. Are there any nice examples made with B4J I could evaluate?
(self promote :p ) :
https://www.b4x.com/android/forum/t...ion-scheduling-project-management-tool.60005/

Edit: you may want to have a look at ABMaterial, for Webapps it's very nice.
 
Last edited:
Upvote 0

Martin Larsen

Active Member
Licensed User
Longtime User
2. You can use JavaObject to inject JavaScript: https://www.b4x.com/android/forum/threads/webview.36582/#post-310881
I don't recommend you to implement the interface based on WebView unless you must.

It's not the UI that is based on WebView. But the Chrome app uses a webview as a built-in browser to show websites which the app can then process.

From your referred post I see that you can inject JS to the pages. Nice!

In Chrome apps and extensions you can also process and manipulate the individual requests in the webview.

For example, this will inject a X-Forwarded-For http header to every requests:

B4X:
wv.request.onBeforeSendHeaders.addListener(
  function(details) {
   details.requestHeaders.push({name: "X-Forwarded-For", value: "x.x.x.x"});
   return {requestHeaders: details.requestHeaders};
  },
  {urls: ["<all_urls>" ]},
  ["blocking", "requestHeaders"]
);

Is this also possible with B4J's webview?
 
Upvote 0

Martin Larsen

Active Member
Licensed User
Longtime User
Thanks.

It's actually not JS injection, it's an event listener on web requests from the webview that also allow you to add custom HTTP headers on the fly. That is not possible using JS injection.

But the webview might have similar possibilitíes?
 
Upvote 0
Top