本文整理汇总了Java中android.webkit.ConsoleMessage类的典型用法代码示例。如果您正苦于以下问题:Java ConsoleMessage类的具体用法?Java ConsoleMessage怎么用?Java ConsoleMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConsoleMessage类属于android.webkit包,在下文中一共展示了ConsoleMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onConsoleMessage
import android.webkit.ConsoleMessage; //导入依赖的package包/类
@Override
public boolean onConsoleMessage(ConsoleMessage m) {
switch (m.messageLevel()) {
case LOG:
Log.i(LOG_TAG, String.format("%s (%s:%d)", m.message(), m.sourceId(), m.lineNumber()));
return true;
case TIP:
Log.v(LOG_TAG, String.format("%s (%s:%d)", m.message(), m.sourceId(), m.lineNumber()));
return true;
case DEBUG:
Log.d(LOG_TAG, String.format("%s (%s:%d)", m.message(), m.sourceId(), m.lineNumber()));
return true;
case WARNING:
Log.w(LOG_TAG, String.format("%s (%s:%d)", m.message(), m.sourceId(), m.lineNumber()));
return true;
case ERROR:
Log.e(LOG_TAG, String.format("%s (%s:%d)", m.message(), m.sourceId(), m.lineNumber()));
return true;
}
return false;
}
示例2: init
import android.webkit.ConsoleMessage; //导入依赖的package包/类
private void init(AttributeSet attrs) {
setAttrs(attrs);
// setWebViewClient(new WebViewClient());
setWebChromeClient(new WebChromeClient() {
public boolean onConsoleMessage(ConsoleMessage cm) {
Log.d("MyApplication", cm.message() + " -- From line "
+ cm.lineNumber() + " of "
+ cm.sourceId() );
return true;
}
});
setVerticalScrollBarEnabled(false);
setHorizontalScrollBarEnabled(false);
WebSettings webSettings = getSettings();
webSettings.setJavaScriptEnabled(true);
}
示例3: onConsoleMessage
import android.webkit.ConsoleMessage; //导入依赖的package包/类
@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;
}
示例4: onConsoleMessage
import android.webkit.ConsoleMessage; //导入依赖的package包/类
public final boolean onConsoleMessage(ConsoleMessage paramConsoleMessage)
{
String str = "JS: " + paramConsoleMessage.message() + " (" + paramConsoleMessage.sourceId() + ":" + paramConsoleMessage.lineNumber() + ")";
if (str.contains("Application Cache")) {
return super.onConsoleMessage(paramConsoleMessage);
}
switch (7.zzNj[paramConsoleMessage.messageLevel().ordinal()])
{
default:
zzb.i(str);
}
for (;;)
{
return super.onConsoleMessage(paramConsoleMessage);
zzb.e(str);
continue;
zzb.w(str);
continue;
zzb.i(str);
continue;
zzb.d(str);
}
}
示例5: onConsoleMessage
import android.webkit.ConsoleMessage; //导入依赖的package包/类
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;
}
示例6: onConsoleMessage
import android.webkit.ConsoleMessage; //导入依赖的package包/类
public final boolean onConsoleMessage(ConsoleMessage paramConsoleMessage)
{
String str = "JS: " + paramConsoleMessage.message() + " (" + paramConsoleMessage.sourceId() + ":" + paramConsoleMessage.lineNumber() + ")";
switch (7.jg[paramConsoleMessage.messageLevel().ordinal()])
{
default:
break;
case 1:
ct.s(str);
break;
case 2:
ct.v(str);
break;
case 3:
case 4:
ct.t(str);
break;
case 5:
ct.r(str);
break;
}
ct.t(str);
return super.onConsoleMessage(paramConsoleMessage);
}
示例7: SoomlaTwitterWebView
import android.webkit.ConsoleMessage; //导入依赖的package包/类
/**
* 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();
}
示例8: onViewCreated
import android.webkit.ConsoleMessage; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mToolbar.setNavigationOnClickListener(v -> getFragmentManager().popBackStack());
if (Build.VERSION.SDK_INT >= 11) {
mWebView.getSettings().setDisplayZoomControls(false);
}
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.getSettings().setUseWideViewPort(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.setInitialScale(1);
mWebView.setWebViewClient(new CustomWebViewClient());
mWebView.setWebChromeClient(new WebChromeClient() {
public boolean onConsoleMessage(ConsoleMessage cm) {
Timber.d("Webview Console", cm.message() + " -- From line "
+ cm.lineNumber() + " of "
+ cm.sourceId());
return true;
}
});
prepareSplitActionBar();
}
示例9: addMessageToConsole
import android.webkit.ConsoleMessage; //导入依赖的package包/类
@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));
}
示例10: onConsoleMessage
import android.webkit.ConsoleMessage; //导入依赖的package包/类
/**
* @see AwContentsClient#onConsoleMessage(android.webkit.ConsoleMessage)
*/
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
TraceEvent.begin();
boolean result;
if (mWebChromeClient != null) {
if (TRACE) Log.d(TAG, "onConsoleMessage");
result = mWebChromeClient.onConsoleMessage(consoleMessage);
String message = consoleMessage.message();
if (result && message != null && message.startsWith("[blocked]")) {
Log.e(TAG, "Blocked URL: " + message);
}
} else {
result = false;
}
TraceEvent.end();
return result;
}
示例11: onConsoleMessage
import android.webkit.ConsoleMessage; //导入依赖的package包/类
public boolean onConsoleMessage(final ConsoleMessage cm) {
final MessageLevel level = cm.messageLevel();
final String msg = cm.message() + " -- From line " + cm.lineNumber()
+ " of " + cm.sourceId();
if (level.compareTo(MessageLevel.DEBUG) == 0) {
Log.d(Constants.LOG_TAG, msg);
} else if (level.compareTo(MessageLevel.ERROR) == 0) {
Log.e(Constants.LOG_TAG, msg);
} else if (level.compareTo(MessageLevel.WARNING) == 0) {
Log.w(Constants.LOG_TAG, msg);
} else {
Log.d(Constants.LOG_TAG, msg);
}
return true;
}
示例12: onConsoleMessage
import android.webkit.ConsoleMessage; //导入依赖的package包/类
@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);
}
示例13: onConsoleMessage
import android.webkit.ConsoleMessage; //导入依赖的package包/类
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
/*onConsoleMessage(consoleMessage.message(), consoleMessage.lineNumber(),
consoleMessage.sourceId());*/
if (this.mRealWebChromeClient != null)
return this.mRealWebChromeClient.onConsoleMessage(consoleMessage);
return super.onConsoleMessage(consoleMessage);
}
示例14: onConsoleMessage
import android.webkit.ConsoleMessage; //导入依赖的package包/类
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
if (consoleMessage.messageLevel() == ConsoleMessage.MessageLevel.DEBUG) {
Log.d(TAG, "onConsoleMessage " + consoleMessage.sourceId() + " "
+ consoleMessage.lineNumber() + ":" + consoleMessage.message()) ;
return true;
}
return super.onConsoleMessage(consoleMessage);
}
示例15: onConsoleMessage
import android.webkit.ConsoleMessage; //导入依赖的package包/类
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
if (consoleMessage == null) {
return false;
}
f.c("WebConsole", consoleMessage.message() + " -- From 111 line " + consoleMessage.lineNumber() + " of " + consoleMessage.sourceId());
if (VERSION.SDK_INT > 7) {
this.a.onConsoleMessage(consoleMessage == null ? "" : consoleMessage.message());
}
return true;
}