android.webkit.ConsoleMessage Java Examples

The following examples show how to use android.webkit.ConsoleMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomWebViewActivity.java    From JsBridge with Apache License 2.0 6 votes vote down vote up
public CustomWebView(Context context) {
    super(context);
    this.webView = new WebView(context);
    this.webView.getSettings().setJavaScriptEnabled(true);
    addView(this.webView);
    this.webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public boolean onJsPrompt(WebView view, String url,
                                  String message, String defaultValue, JsPromptResult result) {
            if (callback != null) {
                callback.onResult(message, new PromptResultImpl(result));
            }
            return true;
        }

        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            Log.d(JsBridge.TAG, consoleMessage.message());
            return true;
        }
    });
}
 
Example #2
Source File: AwWebContentsDelegateAdapter.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public boolean addMessageToConsole(int level, String message, int lineNumber,
        String sourceId) {
    ConsoleMessage.MessageLevel messageLevel = ConsoleMessage.MessageLevel.DEBUG;
    switch(level) {
        case LOG_LEVEL_TIP:
            messageLevel = ConsoleMessage.MessageLevel.TIP;
            break;
        case LOG_LEVEL_LOG:
            messageLevel = ConsoleMessage.MessageLevel.LOG;
            break;
        case LOG_LEVEL_WARNING:
            messageLevel = ConsoleMessage.MessageLevel.WARNING;
            break;
        case LOG_LEVEL_ERROR:
            messageLevel = ConsoleMessage.MessageLevel.ERROR;
            break;
        default:
            Log.w(TAG, "Unknown message level, defaulting to DEBUG");
            break;
    }

    return mContentsClient.onConsoleMessage(
            new ConsoleMessage(message, sourceId, lineNumber, messageLevel));
}
 
Example #3
Source File: UpToStream.java    From xGetter with Apache License 2.0 6 votes vote down vote up
@SuppressLint("JavascriptInterface")
public void get(Context context, final String js, final OnDone onDone){
    this.onDone = onDone;
    webView = new WebView(context);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebChromeClient(new WebChromeClient(){
        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            System.out.println(consoleMessage.message());
            String msg = consoleMessage.message().toLowerCase();
            if (msg.contains("sources is not defined")){
                destroyWebView();
                onDone.result(null);
            }else if (consoleMessage.message().toLowerCase().contains("error")){
                destroyWebView();
                System.out.println("Retry");
                onDone.retry();
            }
            return super.onConsoleMessage(consoleMessage);
        }
    });
    webView.addJavascriptInterface(new MyInterface(),"xGetter");
    inject(js);
}
 
Example #4
Source File: PermissionRequestFragment.java    From android-PermissionRequest with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onConsoleMessage(@NonNull ConsoleMessage message) {
    switch (message.messageLevel()) {
        case TIP:
            Log.v(TAG, message.message());
            break;
        case LOG:
            Log.i(TAG, message.message());
            break;
        case WARNING:
            Log.w(TAG, message.message());
            break;
        case ERROR:
            Log.e(TAG, message.message());
            break;
        case DEBUG:
            Log.d(TAG, message.message());
            break;
    }
    if (null != mConsoleMonitor) {
        mConsoleMonitor.onConsoleMessage(message);
    }
    return true;
}
 
Example #5
Source File: BridgeWebChromeClient.java    From OsmGo with MIT License 6 votes vote down vote up
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
  String tag = "Capacitor/Console";
  if (consoleMessage.message() != null && isValidMsg(consoleMessage.message())) {
    String msg = String.format("File: %s - Line %d - Msg: %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
    String level = consoleMessage.messageLevel().name();
    if ("ERROR".equalsIgnoreCase(level)) {
      Log.e(tag, msg);
    } else if ("WARNING".equalsIgnoreCase(level)) {
      Log.w(tag, msg);
    } else if ("TIP".equalsIgnoreCase(level)) {
      Log.d(tag, msg);
    } else {
      Log.i(tag, msg);
    }
  }
  return true;
}
 
Example #6
Source File: WebPlayerView.java    From unity-ads-android with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
	Boolean returnValue = false;

	if (shouldCallSuper("onConsoleMessage")) {
		returnValue = super.onConsoleMessage(consoleMessage);
	}
	if (shouldSendEvent("onConsoleMessage")) {
		String message = "";
		if (consoleMessage != null) {
			message = consoleMessage.message();
		}
		WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.CONSOLE_MESSAGE, message, viewId);
	}
	if (hasReturnValue("onConsoleMessage")) {
		returnValue = getReturnValue("onConsoleMessage", java.lang.Boolean.class, true);
	}

	return returnValue;
}
 
Example #7
Source File: H.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public boolean onConsoleMessage(ConsoleMessage consolemessage)
{
    Log.i("WebConsole", (new StringBuilder()).append(consolemessage.message()).append(" -- From  111 line ").append(consolemessage.lineNumber()).append(" of ").append(consolemessage.sourceId()).toString());
    if (android.os.Build.VERSION.SDK_INT > 7)
    {
        d d1 = a;
        String s;
        if (consolemessage == null)
        {
            s = "";
        } else
        {
            s = consolemessage.message();
        }
        d1.onConsoleMessage(s);
    }
    return true;
}
 
Example #8
Source File: SoomlaTwitterWebView.java    From android-profile with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor
 *
 * @param parentActivity the parent activity of the web-view, which will
 *                       be used as a context
 */
public SoomlaTwitterWebView(Activity parentActivity) {
    super(parentActivity);

    this.getSettings().setJavaScriptEnabled(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        this.getSettings().setAllowUniversalAccessFromFileURLs(true);
    }

    this.mHandler = new Handler(Looper.getMainLooper());

    this.setWebChromeClient(new WebChromeClient() {
        public boolean onConsoleMessage(ConsoleMessage cm) {
            Log.d(TAG, cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId());
            return true;
        }
    });

    this.setBackgroundColor(0x00000000);
    this.mTranslucent = true;
    postInvalidate();
}
 
Example #9
Source File: WebView.java    From Small with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
    String msg = consoleMessage.message();
    if (msg == null)
        return false;
    Uri uri = Uri.parse(msg);
    if (uri != null && null != uri.getScheme() && uri.getScheme().equals(SMALL_SCHEME))
    {
        String host = uri.getHost();
        String ret = uri.getQueryParameter(SMALL_QUERY_KEY_RET);
        if (host.equals(SMALL_HOST_POP)) {
            WebActivity activity = mWebView.getActivity();
            if (activity != null) {
                activity.finish(ret);
            }
        } else if (host.equals(SMALL_HOST_EXEC)) {
            if (mWebView.mOnResultListener != null) {
                mWebView.mOnResultListener.onResult(ret);
            }
        }
        return true;
    }
    Log.d(consoleMessage.sourceId(),
            "line" + consoleMessage.lineNumber() + ": " + consoleMessage.message());
    return true;
}
 
Example #10
Source File: AwWebContentsDelegateAdapter.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public boolean addMessageToConsole(int level, String message, int lineNumber,
        String sourceId) {
    ConsoleMessage.MessageLevel messageLevel = ConsoleMessage.MessageLevel.DEBUG;
    switch(level) {
        case LOG_LEVEL_TIP:
            messageLevel = ConsoleMessage.MessageLevel.TIP;
            break;
        case LOG_LEVEL_LOG:
            messageLevel = ConsoleMessage.MessageLevel.LOG;
            break;
        case LOG_LEVEL_WARNING:
            messageLevel = ConsoleMessage.MessageLevel.WARNING;
            break;
        case LOG_LEVEL_ERROR:
            messageLevel = ConsoleMessage.MessageLevel.ERROR;
            break;
        default:
            Log.w(TAG, "Unknown message level, defaulting to DEBUG");
            break;
    }

    return mContentsClient.onConsoleMessage(
            new ConsoleMessage(message, sourceId, lineNumber, messageLevel));
}
 
Example #11
Source File: CordovaChromeClient.java    From phonegap-plugin-loading-spinner with Apache License 2.0 5 votes vote down vote up
@TargetApi(8)
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #12
Source File: CBrowserMainFrame7.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
    if (WDataManager.sRootWgt!=null&&WDataManager.sRootWgt.m_appdebug==1 && !TextUtils.isEmpty(WDataManager.sRootWgt.m_logServerIp)) {
        if (consoleMessage.messageLevel() != ConsoleMessage.MessageLevel.WARNING) {//过滤掉warning
            BDebug.sendUDPLog(formatConsole(consoleMessage));
        }
    }
    return super.onConsoleMessage(consoleMessage);
}
 
Example #13
Source File: CBrowserMainFrame7.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static String formatConsole(ConsoleMessage consoleMessage){
    StringBuilder stringBuilder=new StringBuilder();
    stringBuilder.append("[ ")
            .append(simpleSourceInfo(consoleMessage.sourceId()))
            .append(" line : ")
            .append(consoleMessage.lineNumber())
            .append(" ")
            .append(consoleMessage.messageLevel().toString().toLowerCase())
            .append(" ]\n")
            .append(consoleMessage.message())
            .append("\n");
    return stringBuilder.toString();
}
 
Example #14
Source File: CordovaChromeClient.java    From phonegapbootcampsite with MIT License 5 votes vote down vote up
@TargetApi(8)
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #15
Source File: CordovaChromeClient.java    From CordovaYoutubeVideoPlayer with MIT License 5 votes vote down vote up
@TargetApi(8)
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #16
Source File: GAEChannelClient.java    From droidkit-webrtc with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Asynchronously open an AppEngine channel. */
@SuppressLint("SetJavaScriptEnabled")
public GAEChannelClient(
    Activity activity, String token, MessageHandler handler) {
  webView = new WebView(activity);
  webView.getSettings().setJavaScriptEnabled(true);
  webView.setWebChromeClient(new WebChromeClient() {  // Purely for debugging.
      public boolean onConsoleMessage (ConsoleMessage msg) {
        Log.d(TAG, "console: " + msg.message() + " at " +
            msg.sourceId() + ":" + msg.lineNumber());
        return false;
      }
    });
  webView.setWebViewClient(new WebViewClient() {  // Purely for debugging.
      public void onReceivedError(
          WebView view, int errorCode, String description,
          String failingUrl) {
        Log.e(TAG, "JS error: " + errorCode + " in " + failingUrl +
            ", desc: " + description);
      }
    });
  proxyingMessageHandler =
      new ProxyingMessageHandler(activity, handler, token);
  webView.addJavascriptInterface(
      proxyingMessageHandler, "androidMessageHandler");
  webView.loadUrl("file:///android_asset/channel.html");
}
 
Example #17
Source File: CordovaChromeClient.java    From cordova-android-chromeview with Apache License 2.0 5 votes vote down vote up
@TargetApi(8)
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #18
Source File: CordovaChromeClient.java    From reader with MIT License 5 votes vote down vote up
@TargetApi(8)
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #19
Source File: SystemWebChromeClient.java    From pychat with MIT License 5 votes vote down vote up
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(LOG_TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #20
Source File: BaseWebChromeClient.java    From mobile-sdk-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
    Clog.v(Clog.jsLogTag,
            Clog.getString(com.appnexus.opensdk.R.string.console_message,
                    consoleMessage.message(),
                    consoleMessage.lineNumber(),
                    consoleMessage.sourceId()));
    return true;
}
 
Example #21
Source File: SystemWebChromeClient.java    From chappiecast with Mozilla Public License 2.0 5 votes vote down vote up
@TargetApi(8)
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(LOG_TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #22
Source File: CordovaChromeClient.java    From bluemix-parking-meter with MIT License 5 votes vote down vote up
@TargetApi(8)
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #23
Source File: SystemWebChromeClient.java    From cordova-plugin-intent with MIT License 5 votes vote down vote up
@TargetApi(8)
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(LOG_TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #24
Source File: SystemWebChromeClient.java    From a2cardboard with Apache License 2.0 5 votes vote down vote up
@TargetApi(8)
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(LOG_TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #25
Source File: KCWebChromeClient.java    From kerkee_android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{

    // we MUST return true we are done with debugging
    return !mEnableConsoleLog; // return false to enable console.log
}
 
Example #26
Source File: CordovaChromeClient.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
@TargetApi(8)
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #27
Source File: SystemWebChromeClient.java    From countly-sdk-cordova with MIT License 5 votes vote down vote up
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(LOG_TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #28
Source File: CordovaChromeClient.java    From L.TileLayer.Cordova with MIT License 5 votes vote down vote up
@TargetApi(8)
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #29
Source File: SystemWebChromeClient.java    From BigDataPlatform with GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(8)
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage)
{
    if (consoleMessage.message() != null)
        LOG.d(LOG_TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
     return super.onConsoleMessage(consoleMessage);
}
 
Example #30
Source File: VideoChromeClient.java    From mobile-sdk-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
    Clog.v(Clog.jsLogTag,
            Clog.getString(R.string.console_message,
                    consoleMessage.message(),
                    consoleMessage.lineNumber(),
                    consoleMessage.sourceId()));
    return true;
}