问题:
在人行横道浏览器(XWalkView)中多次单击任何html页面的任何按钮(html中的输入标签)在Android中不起作用。 (单击第一次工作,但之后单击按钮除了Eclipse IDE的Logcat中的跟随错误之外没有任何响应,即单击输入类型文件首次显示文件选择器但多次单击同一按钮,得到没有回复。但重新启动应用后,流程重复进行。这真的是一种奇怪的行为。)
错误:
每次点击任何按钮(输入标签)时都会显示此错误消息。
11-20 17:32:04.019: E/chromium(31406): [ERROR:xwalk_autofill_client.cc(170)] Not implemented reached in virtual void xwalk::XWalkAutofillClient::OnFirstUserGestureObserved()
代码:
的index.html
<html>
<body>
<form>
<input type="file" accept="*/*"/>
<input type="submit"/>
</form>
</body>
</html>
MainActivity.java
import org.xwalk.core.XWalkView;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
public class MainActivity extends Activity {
private LinearLayout linearLayout;
private XWalkView xWalkWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
linearLayout = (LinearLayout) findViewById(R.id.LinearLayout1);
xWalkWebView = new XWalkView(this.getApplicationContext(), this);
xWalkWebView.load("file:///android_asset/index.html", null);
linearLayout.addView(xWalkWebView);
}
}
答案 0 :(得分:7)
添加以下代码解决了问题:
@Override
protected void onPause() {
super.onPause();
if (mXwalkView != null) {
mXwalkView.pauseTimers();
mXwalkView.onHide();
}
}
@Override
protected void onResume() {
super.onResume();
if (mXwalkView != null) {
mXwalkView.resumeTimers();
mXwalkView.onShow();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mXwalkView != null) {
mXwalkView.onDestroy();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (mXwalkView != null) {
mXwalkView.onActivityResult(requestCode, resultCode, data);
}
}
@Override
protected void onNewIntent(Intent intent) {
if (mXwalkView != null) {
mXwalkView.onNewIntent(intent);
}
}
提及here