Any android view including XWalkView must live in a “Window”.  Window can be 
Activity/PopupWindow/Dialog/…
Without “Window”, you cannot put android view into Service.

Do you have any kind of “Window” in your service? Did you try any other android 
view in your service?

Regards,
Xing

From: Crosswalk-help 
[mailto:[email protected]] On Behalf Of Kamil 
Krzyszczuk
Sent: Monday, August 10, 2015 11:24 PM
To: [email protected]
Subject: [Crosswalk-help] How to instantiate XWalkView or XWalkViewInternal 
inside a Service instead of Activity

As in title: How to instantiate XWalkView or XWalkViewInternal inside a Service 
instead of Activity

It gives me runtime errors in every scenarios:


webView = new XWalkView(this);

webView = new XWalkView(this, (Activity)null);
and XWalkViewInternal too, for example error output:

Process: com.example.test, PID: 28970
    java.lang.RuntimeException: Unable to start service 
com.example.test.Service@42d4d600<mailto:com.example.test.Service@42d4d600> 
with Intent { cmp=com.example.test/.Service}: java.lang.NullPointerException
            at 
android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3044)
            at android.app.ActivityThread.access$2200(ActivityThread.java:172)
            at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5694)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at 
org.xwalk.core.internal.XWalkInternalResources.doResetIds(XWalkInternalResources.java:28)
            at 
org.xwalk.core.internal.XWalkInternalResources.resetIds(XWalkInternalResources.java:72)
            at 
org.xwalk.core.internal.XWalkViewDelegate.init(XWalkViewDelegate.java:130)
            at 
org.xwalk.core.internal.XWalkViewDelegate.init(XWalkViewDelegate.java:89)
            at 
org.xwalk.core.internal.XWalkViewInternal.init(XWalkViewInternal.java:261)
            at 
org.xwalk.core.internal.XWalkViewInternal.<init>(XWalkViewInternal.java:254)
            at com.example.test.Service.startWebView(Service.java:184)
            at com.example.test.Service.onStartCommand(Service.java:107)
            at 
android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3027)
            at android.app.ActivityThread.access$2200(ActivityThread.java:172)
            at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5694)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
            at dalvik.system.NativeStart.main(Native Method)
_______________________________________________
Crosswalk-help mailing list
[email protected]
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help

Reply via email to