I need to download a file from webview in android. Now this works great, except for the android kitkat. I reviewed the following.
https://code.google.com/p/android/issues/detail?id=62220
Entering HTML file in Android web browser (android 4.4, kitkat)
As suggested in the second question (agomes answer), I tried using a pedestrian crossing. I use eclipse, I followed the instructions for setting up a simple Crosswalk web browser, but the application continues to crash. f someone knows a simpler / better way to download images from a webview in Android 4.4.2, and will also be useful.
I cannot use cordova as I cannot change the server side code.
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() {
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 file:
<?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>
Stack trace:
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
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
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
. I