Questions tagged [android-jsinterface]

Android's `JavascriptInterface` is an interface that allows calling of native (Java) code from an embedded Webkit Webview. Security precautions should be taken to ensure that only your own pages will run in the webview, or that all Java code that can be called will not cause a security breach.

Android's JavascriptInterface is an interface that allows calling of native (Java) code from an embedded Webkit Webview. Security precautions should be taken to ensure that only your own pages will run in the webview, or that all Java code that can be called will not cause a security breach.

Official documentation: https://developer.android.com/guide/webapps/webview.html#AddingWebView

34 questions
1
vote
0 answers

JS interface doesn't work with Android Kotlin

I am trying to implement JS interface in my WebView. I created a separate class with a method which calls listener, subsequently the string caught by listener should be put in the intent (in MainActivity) and intent finishes. MainActivity.kt: import…
prosyanoy
  • 43
  • 4
1
vote
1 answer

JavaScript callbacks aren't being reached with android JSInterface

I want to know when responsivevoice (JS) is done speaking. In the docs here, it shows I can pass callbacks like onstart/onend. So, I made a JSInterface and attached it to the WebView that calls my JS function. However I must not be doing it…
sadelbrid
  • 411
  • 1
  • 4
  • 16
1
vote
0 answers

ClipBorad's Clip text is not comming directly after putting it in android

Here I am trying to get clipboard text I have tried both ways first i tried with clipboard and second with sharedpreferences in both the cases behaviour is same when i select the word from my custom webview and copy that word using jsinterface i got…
1
vote
1 answer

WebView load url in fragment from another class

I want to call method for loading URL in Fragment Class from other class , But I am getting null value for web view. Below is my code. …
user4822839
1
vote
1 answer

Why is Android JSInterface so slow?

I have a javascript calling a javascript interface many times (around 500 times sometimes), updating the page's UI from it. It sends a couple strings, and casts String result to string: ""+window.INTERFACENAME.function(...). Without calling the…
NoBugs
  • 9,310
  • 13
  • 80
  • 146
0
votes
0 answers

Injecting JS code into Webview via loadurl differs in behaviour depending on Webview version and place of injection

Background - We use Grafana to show some data on app in a webview. But Grafana is not supported older version of webviews hence we decided to inject a JS code to detect if Grafana can be run on this version or not and generate corresponding event.…
0
votes
2 answers

Admob interstitial Ads aren't clickable when called from Webview

Hey I have a web html5 game and I built an app for it, to monetize it with Admob. I use JavaScript Interface to handle app event from the JavaScript code. Most of the things works fine but the ads shown are not clickable. Part of them are completely…
0
votes
1 answer

How can i catch all the javascript console warnings and perform actions based on different warnings

I have an html content which when loaded to the webview throws some warnings in console. Is there any way to capture and compare these warnings to perform specific actions for specific warning in javascript.
Midhun Kumar
  • 549
  • 5
  • 23
0
votes
1 answer

How to set window.onerror for a webview in android

I have a webview and the javascript interface is also there. How can I add a window.onerror for it? The main requirement is that when I load the webview with content the otf files are throwing some invalid tag error ("OTS parsing error: invalid…
0
votes
1 answer

How to run .js files in webview from android below 5.0?

I have some .js file with me. I load that html file from assets folder.` WebView browser=(WebView) findViewById(R.id.webView); browser.getSettings().setJavaScriptEnabled(true); browser.loadUrl("file:///android_asset/network.html");` Its…
Venkat
  • 3,447
  • 6
  • 42
  • 61
0
votes
3 answers

Android InApp, java.lang.NullPointerException purchasing item from JsInterface

I'm trying to purchase an item in my android app when the user clicks on a button through JsInterface. The method purchaseItem() is executed but launchPurchaseFlow() inside this method is not. Do you know the solution to this issue ? OnCreate() i…
0
votes
0 answers

Call method from another activity through JsInterface

I'm trying to develop a way to fire inapp purchase from a JSInterface. I have two classes. The first one is MainActivity, in which i implemented inAppBilling with Iabhelper. This activity contains the method i use to purchase an item : protected…
0
votes
1 answer

Overwriting javascript function call from Android interface

I have a webpage displayed in a WebView. I do not have the control of the webpage. The webpage is executing a javascript and when it's resoving a deffered object it loads an URL. What I want is to capture the deffered.resolve() and do something…
ftraian
  • 658
  • 1
  • 7
  • 21
0
votes
1 answer

Android: Playing html videos in full screen

I am loading a HTML page on to a webview, which has a list of videos. Now when I try to play the videos, they are playing but I am unable to make them play in full screen. I have used the below code in my HTML file, and on debugging found that…
0
votes
1 answer

Change on activity via JsInterface

Peace be upon you. I'm working for a Web-view app and want to change on the activity via JavaScript. First I've added a JavascriptInterface for my WebView: wv.addJavascriptInterface(new JsInterface(this), "android"); And this is the class: public…
Ahmed Sabry
  • 434
  • 1
  • 8
  • 17