4

我必须从 android 的 webview 上传文件。现在,除了 android kitkat 之外,这一切正常。我经历了以下。

https://code.google.com/p/android/issues/detail?id=62220

android webview中的HTML文件输入(android 4.4,kitkat)

正如第二个问题(agomes answer)中所建议的那样,我尝试使用人行横道。我正在使用 eclipse,我按照说明设置了一个简单的 Crosswalk webview,但应用程序不断崩溃。f 有人知道在 Android 4.4.2 中从 webview 上传图像的更简单/更好的方法也会有所帮助。

我不能使用cordova,因为我不能在服务器端更改代码。

    //Webview Activity
    public class MainXWalkActivity extends XWalkActivity{


private XWalkView mXWalkView;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.fragment_falcon_management);
    super.onCreate(savedInstanceState);

  //        
  }

@Override
protected void onXWalkReady() {
    // TODO Auto-generated method stub
    initViews();
    mXWalkView.load("http://crosswalk-project.org/", null);
}
private void initViews(){

    mXWalkView = (XWalkView) findViewById(R.id.xwalkWebView);
    mXWalkView.setUIClient(new XWalkUIClient(mXWalkView));
    mXWalkView.setResourceClient(new XWalkResourceClient(mXWalkView));
    XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
}

}

XML文件是:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/bg_app"
        android:orientation="vertical" >

       <org.xwalk.core.XWalkView
         android:id="@+id/xwalkWebView"
         android:orientation="vertical"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:background="#000000"
         />

   </LinearLayout>

堆栈跟踪是:

    11-18 20:09:42.019: E/AndroidRuntime(22584): java.lang.RuntimeException: Unable to start activity ComponentInfo{android.settings.MainXWalkActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class org.xwalk.core.XWalkView
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2282)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.app.ActivityThread.access$800(ActivityThread.java:157)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.os.Handler.dispatchMessage(Handler.java:102)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.os.Looper.loop(Looper.java:157)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.app.ActivityThread.main(ActivityThread.java:5293)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at java.lang.reflect.Method.invokeNative(Native Method)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at java.lang.reflect.Method.invoke(Method.java:515)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at dalvik.system.NativeStart.main(Native Method)
    11-18 20:09:42.019: E/AndroidRuntime(22584): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class org.xwalk.core.XWalkView
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.view.LayoutInflater.createView(LayoutInflater.java:626)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:340)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.app.Activity.setContentView(Activity.java:1973)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.settings.MainXWalkActivity.onCreate(MainXWalkActivity.java:20)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.app.Activity.performCreate(Activity.java:5389)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    ... 11 more
    11-18 20:09:42.019: E/AndroidRuntime(22584): Caused by: java.lang.reflect.InvocationTargetException
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at java.lang.reflect.Constructor.constructNative(Native Method)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at android.view.LayoutInflater.createView(LayoutInflater.java:600)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    ... 22 more
    11-18 20:09:42.019: E/AndroidRuntime(22584): Caused by: junit.framework.AssertionFailedError: Please have your activity extend XWalkActivity for shared mode
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at junit.framework.Assert.fail(Assert.java:50)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at org.xwalk.core.XWalkCoreWrapper.initEmbeddedMode(XWalkCoreWrapper.java:189)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at org.xwalk.core.XWalkView.reflectionInit(XWalkView.java:761)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    at org.xwalk.core.XWalkView.     <init>(XWalkView.java:221)
    11-18 20:09:42.019: E/AndroidRuntime(22584):    ... 25 more

任何帮助来完成这项工作将不胜感激。我

4

0 回答 0