2016-02-22 78 views
1

在我的cn1應用程序中,我有一些內容我想要顯示的內容已經被格式化爲HTML,所以我認爲最好的做法是堅持使用WebView,而不是嘗試解析它並創建單獨的cn1組件爲每個段落等cn1 - webview不能正常工作

問題是,我不能說服應用程序實際顯示它。

這裏是我的代碼:

WebBrowser web = new WebBrowser(); 
web.setURL(StateMachine.URL_PREFIX + "/api/article_body.php?articleId=" + (String)map.get("id")); 
mac.findArticleBodyContainer(f).addComponent(BorderLayout.CENTER, web); 
form.revalidate(); 

這裏的logcat的輸出,當我打開應用程序在Android設備上(運行棉花糖,以前用棒棒糖它也不能工作,但我沒有日誌從那個):

02-22 11:08:01.844 25899-25899/? W/AwContents: onDetachedFromWindow called when already detached. Ignoring 
02-22 11:08:01.849 25899-25899/? W/ResourceType: No package identifier when getting value for resource number 0x00000000 
02-22 11:08:02.188 25899-26296/? E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY) 
02-22 11:08:02.408 25899-25899/? W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 25899 
02-22 11:08:02.956 1786-1786/? W/AutostartServic: type=1400 audit(0.0:4802979): avc: denied { search } for name="26253" dev="proc" ino=2312770 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0 
02-22 11:08:02.956 1786-1786/? W/AutostartServic: type=1400 audit(0.0:4802980): avc: denied { search } for name="26254" dev="proc" ino=2312771 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0 
02-22 11:08:02.956 1786-1786/? W/AutostartServic: type=1400 audit(0.0:4802981): avc: denied { search } for name="26255" dev="proc" ino=2312772 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0 
02-22 11:08:02.956 1786-1786/? W/AutostartServic: type=1400 audit(0.0:4802982): avc: denied { search } for name="26256" dev="proc" ino=2312773 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0 
02-22 11:08:02.956 1786-1786/? W/AutostartServic: type=1400 audit(0.0:4802983): avc: denied { search } for name="26257" dev="proc" ino=2312774 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0 
02-22 11:08:02.956 1786-1786/? W/AutostartServic: type=1400 audit(0.0:4802984): avc: denied { search } for name="26258" dev="proc" ino=2312775 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0 
02-22 11:08:02.956 1786-1786/? W/AutostartServic: type=1400 audit(0.0:4802985): avc: denied { search } for name="26259" dev="proc" ino=2312776 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0 
02-22 11:08:03.160 778-1444/? W/InputMethodManagerService: Window already focused, ignoring focus gain of: [email protected] attribute=null, token = [email protected] 

我還沒有嘗試過任何其他操作系統,雖然我在另一個Android設備(也棉花糖)得到相同的問題。

注意This SO問題有答案,但對於原生Android。我沒有看到以同樣的方式從cn1訪問webview設置的方法。

更新

我感動的HTML內容的應用程序,並從本地文件加載它。我沒有從模擬器中得到任何錯誤,但沒有顯示內容。在我的Android設備,沒有任何顯示,這是來自logcat的新的輸出:

02-23 10:22:28.426 16674-16674/? I/WebViewFactory: Loading com.google.android.webview version 47.0.2526.100 (code 252610000) 
02-23 10:22:28.520 16674-16674/? I/cr_LibraryLoader: Time to load native libraries: 0 ms (timestamps 8908-8908) 
02-23 10:22:28.520 16674-16674/? I/cr_LibraryLoader: Expected native library version number "47.0.2526.100", actual native library version number "47.0.2526.100" 
02-23 10:22:28.546 16674-16674/? I/cr_LibraryLoader: Expected native library version number "47.0.2526.100", actual native library version number "47.0.2526.100" 
02-23 10:22:28.546 16674-16674/? I/chromium: [INFO:library_loader_hooks.cc(122)] Chromium logging enabled: level = 0, default verbosity = 0 
02-23 10:22:28.555 16674-16674/? I/cr_BrowserStartup: Initializing chromium process, singleProcess=true 
02-23 10:22:28.558 16674-16674/? E/SysUtils: ApplicationContext is null in ApplicationStatus 
02-23 10:22:28.615 16674-17002/? W/cr_media: Requires BLUETOOTH permission 
02-23 10:22:28.643 16674-16674/? D/cr_Ime: [InputMethodManagerWrapper.java:27] Constructor 
02-23 10:22:28.652 16674-16674/? D/cr_Ime: [ImeAdapter.java:241] attach 
02-23 10:22:28.661 16674-16674/? W/AwContents: onDetachedFromWindow called when already detached. Ignoring 
02-23 10:22:28.662 16674-16674/? D/cr_Ime: [InputMethodManagerWrapper.java:56] isActive: false 
02-23 10:22:28.666 16674-16674/? W/ResourceType: No package identifier when getting value for resource number 0x00000000 
02-23 10:22:28.728 16674-16674/? D/cr_Ime: [ImeAdapter.java:241] attach 
02-23 10:22:28.766 16674-16674/? D/cr_Ime: [ImeAdapter.java:241] attach 
02-23 10:22:28.824 16674-16674/? D/cr_Ime: [AdapterInputConnection.java:499] finishComposingText 
02-23 10:22:28.827 16674-16674/? D/cr_Ime: [AdapterInputConnection.java:145] Constructor called with outAttrs: inputType=0xa1 imeOptions=0x12000000 privateImeOptions=null 
              actionLabel=null actionId=0 
              initialSelStart=0 initialSelEnd=0 initialCapsMode=0x0 
              hintText=null label=null 
              packageName=il.co.medonline.doctorapp fieldId=-1 fieldName=null 
              extras=null 
02-23 10:22:28.857 16674-16674/? D/cr_Ime: [AdapterInputConnection.java:308] getExtractedText 
02-23 10:22:28.861 16674-16674/? D/cr_Ime: [AdapterInputConnection.java:542] setComposingRegion [0 0] 
02-23 10:22:28.862 16674-16674/? D/cr_Ime: [AdapterInputConnection.java:499] finishComposingText 
02-23 10:22:28.877 16674-17015/? E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY) 
02-23 10:22:28.957 16674-16674/? W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 16674 

兩個相同的不祥之行是否存在:validate_display:255 error 3008Cannot call determinedVisibility()。谷歌搜索這些似乎表明,它們出現在應用程序沒有更新某些安全措施以與Android 5.0及更高版本中使用的Linux內核兼容時出現,但可以通過在原生Android WebView上設置幾個屬性輕鬆解決。 cn1是否可以訪問這些東西,還是應該嘗試使用本地組件?

回答

0

如何在瀏覽器佈局提及?它在模擬器中工作嗎?

我看到你已經將它添加到了邊界佈局,但是如果你將該組件放置在沒有明確增長組件的佈局管理器中,那麼這實際上並不重要。

+0

它在模擬器在某些時候工作,因爲然後我做了一些更改,以嘗試修復它,並且我複製了當前代碼以上,在模擬器中也不起作用。我所看到的無論是在模擬器還是在設備上,都是通過屏幕的一個像素高線,即webview背景的顏色,所以我知道它正在顯示,由於某種原因它只是空的。 – ygesher

+0

將webview添加到邊框佈局的中心,該邊框佈局位於boxYLayout窗體中。這可能是問題的根源嗎? – ygesher

+0

這個答案應該是一個評論 – ygesher

0

我發現你還需要父容器/表單使用邊界佈局,沒有別的。我不知道爲什麼,但以這種方式,它似乎工作...