Android Webview Error Calling Method On Npobject
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn error calling method on npobject applet more about Stack Overflow the company Business Learn more about hiring developers or posting error calling method on npobject javascript ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack error calling method on npobject firefox Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Javascript Interface, error “Uncaught Error: Error calling method on NPObject” up
Error Calling Method On Npobject Safari
vote 3 down vote favorite 1 In my Android application, I am using the WebAppInterface to bridge from Javascript to Java. My .html file includes some JS that runs "Android.canPlay();" at certain times. In my app, the function "canPlay()" fires a variable listener. When the variable listener fires, if conditions are met, some files are renamed (temporary files, that were downloaded with a .tmp additional extension, including the uncaught error error calling method on npobject .html file (so it is .html.tmp, with the original .html existing alongside it)) After the renaming happens, the Web View is reloaded (I have tried using both a function and just ".loadUrl()" - both give errors) When time comes to reload the html file in the webview, I get the error: E/Web Console﹕ Uncaught Error: Error calling method on NPObject. at file:////mnt/sdcard/Download/qwerty/playlists/29/2/index.html:206 Line 206 is the "Android.canPlay()" call. Things to note - If I don't rename the files before reloading the webview and instead, rename then from a background service that runs, I don't have this error (although I do get one about running stuff on the WebViewCoreThread) Some code: WebAppInterface public class WebAppInterface { final Context mContext; WebAppInterface(Context c) { mContext = c; } @JavascriptInterface public void canPlay() { mPlaylistReady.changeState(true); } } Variable Listener (gets fired via a listener class) (some bits of code removed e.g. sharedprefences for file locations) @Override public void onStateChange(boolean state) { if (state) { // true // this finds all the files and removes the .tmp extension fileRenamer.removeTmp(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS + "/qwerty/playlists/")); // reloads the webview WebViewActivity.this.runOnUiThread(new Runnable() { public void run() { webView.loadUrl("file:///" + htmlFile.getAbsolutePath()); } }); } } } FileRenamer class public class FileRenamer { public void removeTmp(F
here for a quick overview of the site Help Center Detailed answers to any questions error calling method on npobject android phonegap you might have Meta Discuss the workings and policies of this
Error Calling Method On Npobject Solution
site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers
Error Calling Method On Npobject Silverlight
or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a http://stackoverflow.com/questions/20976487/javascript-interface-error-uncaught-error-error-calling-method-on-npobject community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Android Javascript Interface up vote 1 down vote favorite I have a webview with a javascript method that calls the android Javascript Interface(JAVA) method and in turn the Javscript Interface(JAVA) calls the context(Reader) activity's http://stackoverflow.com/questions/19818649/android-javascript-interface method to open a UI screen. When I run openDiscussionsUI() directly from the ReaderActivity it opens the UI fine but not when it is run from the Javascript Interface, it seems it does not completely run through the openDiscussionsUI() method as if it was interrupted? Hope someone can help me with this. Thanks in advance. javascript method marginIconClick: function (itemId) { activity.startDiscussionsActivity(); } (JAVA) JavaScript Interface Method public void startDiscussionsActivity() { readerActivity.openDiscussionsUI(); Log.e("startDiscussionsActivity","startDiscussionsActivity"); } ReaderActivity method public void openDiscussionsUI() { Log.e("openDiscussionsUI 1","openDiscussionsUI 1"); discussionBox.startAnimation(slidenotesup); Log.e("openDiscussionsUI 2","openDiscussionsUI 2"); discussionBox.setVisibility(View.VISIBLE); Log.e("openDiscussionsUI 3","openDiscussionsUI 3"); discussionDescription.requestFocus(); Log.e("openDiscussionsUI 4","openDiscussionsUI 4"); } This is my log Click on icon number #1 11-06 17:21:39.190 12951-12980/com.double_eye.monamiq E/openDiscussionsUI 1﹕ openDiscussionsUI 1 11-06 17:21:39.190 12951-12980/com.double_eye.monamiq E/openDiscussionsUI 2﹕ openDiscussionsUI 2 Click on icon number #2 11-06 17:22:32.154 12951-12980/com.double_eye.monamiq E/openDiscussionsUI 1﹕ openDiscussionsUI 1 11-06 17:22:32.154 12951-12980/com.double_eye.monamiq E/openDiscussionsUI 2﹕ openDiscussionsUI 2 11-06 17:22:32.154 12951-12980/com.double_eye.monamiq E/openDiscussionsUI 3﹕ openDiscussionsUI 3 11-06 17:22:32.170 12951-12951/com.double_eye.monamiq I/WEBVIEW﹕ Message - 266:Uncaught Error: Error calling method on NPOb
side, the function didn't accept a parameter: public void populateField() {} Simply allowing the Java function to accept a parameter solved https://recalll.co/app/?q=Error%20calling%20method%20on%20NPObject!%20in%20Android%202.2 this error for me. public void populateField(String field) {} This may not be, and probably is not, the only reason this error could be thrown. This is simply how I resolved my specific scenario. Hope this helps! :) Error calling method on NPObject! in Android 2.2 - Stack Overflow View More at http://stackoverflow.com/questions/3344256/error-calling-method-o... Another reason error calling can be a RuntimeException on a WebViewCoreThread. Any exception occurred after receiving @JavascriptInterface call will be logged as NPObject error if still running on a WebView thread. Overall insufficient trace message with little clue about the problem. Correct your issue with handling javascript interface call on a suitable thread. @JavascriptInterface public void jsCall() { error calling method new Thread(new Runnable() { @Override public void run() { Log.v(TAG, "Prepared NullPointerException on " + Thread.currentThread()); String s = null; s.length(); // This will throw NullPointerException } }).start(); } Take this as an addition to @Nico.S's answer. Sometimes throws Uncaught Error: Error calling method on NPObject on A... View More at http://stackoverflow.com/questions/16758397/sometimes-throws-unca... Here's a twist I found on this problem that could be useful for some of the folks running into this problem (and it likely explains intermittent failures that seem to defy explanation)... If any exceptions are thrown (and not caught) in the return handler code prior to allowing the javascript interface callback to return clean, it will propagate back as a failed call and you will also get this error - and it would have nothing to do with missing functions or parameters. The easiest way to find this case (whether or not you use this in your final implementation) is to push whatever handler code you have back on