0

How Can I use XWalkView and WebView in same app different activity? In Android KITKAT webview doesn't support upload. Crosswalk fixed it. But now I use two different webview (XWalkView and WebView) in two different activity.

if(sdkVersion == Build.VERSION_CODES.KITKAT){
        Intent myIntent = new Intent(StartActivity.this, MainActivity.class); // this use XWalkView
        StartActivity.this.startActivity(myIntent);
    } else {
        Intent myIntent = new Intent(StartActivity.this, Main2Activity.class); // this use Webview
        StartActivity.this.startActivity(myIntent);
    }

And get this error

    java.lang.RuntimeException: Unable to start activity
    ComponentInfo{com.example.foo/com.example.foo.Main2Activity}:
    java.lang.ClassCastException: 
    org.xwalk.core.XWalkView cannot be cast to android.webkit.WebView
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2614)
 at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5643)
at java.lang.reflect.Method.invoke(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:372)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
 Caused by: java.lang.ClassCastException: org.xwalk.core.XWalkView cannot be cast to android.webkit.WebView
az.azgram.azgram.Main2Activity.onCreate(Main2Activity.java:74)
at android.app.Activity.performCreate(Activity.java:6100)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2481)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2614) 
at android.app.ActivityThread.access$800(ActivityThread.java:178) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loop(Looper.java:194) 
 at android.app.ActivityThread.main(ActivityThread.java:5643) 
 at java.lang.reflect.Method.invoke(Native Method) 
 at java.lang.reflect.Method.invoke(Method.java:372) 
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) 
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
Farid Valiyev
  • 203
  • 5
  • 20
  • You wouldn't use Webview anymore and why would you mix the two? Pick one and stick with it. Crosswalk in your case . – basic Jul 14 '16 at 17:15
  • Because Crosswalk performance less than Webview in middle and low level power device. – Farid Valiyev Jul 14 '16 at 17:20
  • the logcat says the error occurs during Main2Activity's onCreate, can you post Main2Activity.java? – Bill Jul 14 '16 at 17:35

0 Answers0