Error Calling Method On Npobject Android Webview
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you error calling method on npobject applet might have Meta Discuss the workings and policies of this site error calling method on npobject javascript About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting
Error Calling Method On Npobject Firefox
ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7
Error Calling Method On Npobject Safari
million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Sometimes throws Uncaught Error: Error calling method on NPObject on Android up vote 20 down vote favorite 10 I am having problems with the Webview in Android and it's JavascriptInterfaces. I am passing a string to the uncaught error error calling method on npobject JavascriptInterface. When debugging it, I receive the correct string within my Android application. The problem: Sometimes I get an Uncaught Error: Error calling method on NPObject. Does anybody know why? The Interface in Java: public class JSInterfaceGame extends JSInterface { @JavascriptInterface public void setShareText(String share){ shareText = share; if(mJSInterfaceListener != null) mJSInterfaceListener.onParametersChanged(SHARE_TEXT); } The initialization in the onCreateView-Method within the Fragment: online = (WebView) rootView.findViewById(R.id.online); online.setWebViewClient(new WISWebviewClient() { @Override public void onStatusChanged(final WebView view, int progress, long duration) { //unrelated } }); WebSettings ws = online.getSettings(); ws.setJavaScriptEnabled(true); ws.setUserAgentString(USER_AGENT); ws.setCacheMode(WebSettings.LOAD_DEFAULT); ws.setRenderPriority(WebSettings.RenderPriority.HIGH); SharedPreferences settings = getActivity().getSharedPreferences(GameActivity.PREFERENCES, Context.MODE_PRIVATE); mJSInterface = new JSInterfaceGame(); mJSInterface.setJSInterfaceListener(this); // Defined elsewhere in this class. mJSInterface.setPlayerName(settings.getString(GameActivity.PREFS_PlAYERNAME, null)); online.addJavascriptInterface(mJSInterface, "JSInterface"); online.loadUrl("http://myurl.something"); Call in Javascript: function makeShareText() { var text = "Some text"; console.log(typeof text); // Always a string. JSInterface.setShareText(text); } android android-webview android-jsinterface share|improve this question edited Mar 31 at 9:10 asked May 26 '13 at 10:37 daffunn 3561311 add a comment| 4 Answers 4 active oldest votes up vote 31 dow
here for a quick overview of the site Help Center Detailed answers to any questions you might have
Error Calling Method On Npobject Android Phonegap
Meta Discuss the workings and policies of this site About Us error calling method on npobject solution Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with error calling method on npobject silverlight us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just http://stackoverflow.com/questions/16758397/sometimes-throws-uncaught-error-error-calling-method-on-npobject-on-android 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 method to open a UI screen. When I run http://stackoverflow.com/questions/19818649/android-javascript-interface 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 NPObject. Click on icon number #3 11-06 17:22:52.818 12951-12980/com.double_eye.monamiq E/openDiscussionsUI 1﹕ openDiscussionsUI 1 11-06 17:22:52.818 12951-12980/com.double_eye.monamiq E/openDiscussionsUI 2﹕ open
side, the function didn't accept a parameter: public void populateField() {} Simply allowing the Java function to accept a parameter solved this error for me. public void populateField(String field) {} https://recalll.co/app/?q=Error%20calling%20method%20on%20NPObject!%20in%20Android%202.2 This may not be, and probably is not, the only reason this error https://code.google.com/p/android/issues/detail?id=68948 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 can be a RuntimeException on a WebViewCoreThread. Any exception occurred after receiving @JavascriptInterface call will be logged error calling 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() { 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 } error calling method }).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 onto the UI thread (the callback will not be on the UI thread) - this will allow the callback to return clean and any subsequent exceptions that occur will propagate properly up until you catch them or until the app crashes. Either way you will see exactly what is really happening. Otherwise the u
68948: "Error calling method on NPObject!" this error is UNDEBUGGABLE 5 people starred this issue and may be notified of changes. Back to list Status: Obsolete Owner: ---- Closed: May 2015 Type-Defect Priority-Medium ReportedBy-Developer Sign in to add a comment Reported by matteosi...@gmail.com, Apr 24, 2014 When you have: - a webview - a JavascriptInterface - you call a Java method from JavaScript through a JavascriptInterface - an error occurs in Java code then you get this exception in JavaScript, and only in JavaScript: "Error calling method on NPObject!" This error message does not give even the tenth part of the information you expect from any error message in order to debug. It doesn't even make sense (except to the person who wrote it, I guess) The exception in this situation should contain exactly as much information as any exception that is thrown in any other situation not involving javascript nor a webview. Also, the exception should be logged whether or not you log it from JavaScript, and with a complete backtrace. Oct 9, 2014 #1 timru...@gmail.com All I did was upgrade from Cordova 3.5.0 to 3.6.3 and this message stops my app dead Oct 11, 2014 #2 nand...@fdes.in The same problem here, Upgrades from 3.5.0 to 3.6.3 and i am just seeing this message Oct 11, 2014 #3 timru...@gmail.com For my specific problem of upgrading, it's because my brain was turned off and I did not copy the new cordova.js (and other plugin js files) from my launcher project into the js app that's loaded in the WebView. I had even created an Ant manual step in build for that purpose. Folks remember, duplicate code is a real problem wherever it occurs Sent from my BlackBerry 10 smartphone on the Bell network. Original Message From: android@googlecode.com Sent: Saturday, October 11, 2014 5:01 AM To: timrudy0@gmail.com Reply To: android@googlecode.com Subject: Re: Issue 68948 in android: "Error calling method on NPObject!" this error is UNDEBUGGABLE May 10, 2015 Project Member #4 e...@google.com (No comment was entered for this change.) Status: Obsolete May 20, 2015 #5 matteosi...@gmail.com When you close webview issues here as obsolete, do you copy them to https://code.google.com/p/chromium/issues/ ?? May 23, 2015 #6 hbls00...@gmail.com @5 no. May 24, 2015 #7 matteosi...@gmail.com @6 f***ing unbelievable. So you just massively close issues that have been reported for years and are still unfixed, and wait for users to report them again. Great job. ► Sign in to add a comment Term