Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread Call a js function from an Android app in compressed mode
Mon, Jan 29 2018 8:31 AMPermanent Link

Uli Becker

I created an Android app which uses a webview to display a mobile website made with EWB.
In order to refresh some data of the website when the app is resumed I use a js call like this:

   @Override
   public void onResume(){
       super.onResume();
       myBrowser.loadUrl("javascript:global_refreshdata()");
   }

That works fine as long as the EWB app is not compressed. Is there any way to access a js function from outside using compression?

Thanks Uli
Mon, Jan 29 2018 3:39 PMPermanent Link

Rick

On 30/01/18 00:31, Uli Becker wrote:
> Is there any way to access a js function from outside using compression?
>
>

May not be directly related to your particular issue but there was a
similar discussion here:

https://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_general&msg=12175

--
Rick
Tue, Jan 30 2018 12:00 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< That works fine as long as the EWB app is not compressed. Is there any way to access a js function from outside using compression? >>

Rick did a great thing by digging up that old thread.  In it I show you how to register a callback function with the JS in the browser so that you can have the JS trigger the callback.  It avoids using specific identifiers that could be compressed, while still allowing for the given functionality.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Jan 30 2018 1:19 PMPermanent Link

Uli Becker

Tim,

<<
Rick did a great thing by digging up that old thread.  In it I show you how to register a callback function with the JS in the browser so that you can have the JS trigger the callback.  It avoids using specific identifiers that could be compressed, while still allowing for the given functionality.
>>

Thanks a lot, Rich and Tim!

Uli
Tue, Jan 30 2018 1:19 PMPermanent Link

Uli Becker

I like "Rich" but it should read "Rick" <vbg>

Uli
Tue, Jan 30 2018 1:36 PMPermanent Link

Uli Becker

Tim,

after having had a look at the sample application in the old thread I don't see how I can use that for the scenario I described.

The EWB application is running in an Android WebView and what I'm doing is to call a js function from the Android WebView. My EWB app doesn't know anything about the Android browser.

Or am I missing something basic?

Uli
Mon, Feb 5 2018 2:01 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< after having had a look at the sample application in the old thread I don't see how I can use that for the scenario I described. >>

What is the myBrowser variable supposed to be pointing to in your original JS example ?  If it's a TBrowser instance in your EWB application, then you can definitely use the technique that I described.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Feb 5 2018 2:12 PMPermanent Link

Uli Becker

Tim,

<<What is the myBrowser variable supposed to be pointing to in your original JS example ?  If it's a TBrowser instance in your EWB application, then you can definitely use the technique that I described.>>

MyBrowser is a Webview in the Android app written with Android Studio.

Uli
Mon, Feb 5 2018 2:41 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< MyBrowser is a Webview in the Android app written with Android Studio.  >>

Okay, I read that block of code quickly and assumed it was all JS, not Java mixed with the JS literal.  Yeah, in that case you can't really do what you want.

Tim Young
Elevate Software
www.elevatesoft.com
Image