I have a small application that displays a TabHost at launch. One of the TabHost tabs is an Activity which loads a web page inside a WebView with the following code:
reusableIntent = new Intent().setClass(this, ForumViewActivity.class);
tabHost.addTab(tabHost.newTabSpec("Forum").setContent(reusableIntent).setIndicator(this.getString(R.string.forum)));
And inside the ForumViewActivity.class, this is what happens:
setContentView(R.layout.forum);
browser = (WebView) findViewById(R.id.forumwebviewbrowser);
loadingDialog = ProgressDialog.show(ForumViewActivity.this, "",
"Loading...", false);
loadingDialog.setCancelable(true);
loadingDialog.setCanceledOnTouchOutside(true);
browser.loadUrl("http://forum.aulacremona.com/");
forum.xml is just the definition of a LinearLayout that 开发者_JAVA技巧hosts a WebView called 'forumwebviewbrowser', which I call on.
My problem is: when switching between tabs, i.e. back and forth to and from my "Forum" tab, the application will crash, as in go back to Android desktop/launcher.
If I use the aforementioned method, in which I define the layour in an external .xml file ( the way Google explains it when using WebView ), the app will crash as soon as I switch off the Forum tab and reeneter it; instead, if I define a WebView object inside my class without any xml external resource file, the app will crash after way more retries ( I have to switch in and out the tab more times ).
I have no errors at all in the debugger. Just the warnings:
03-09 11:00:32.765: WARN/InputManagerService(52): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44dc6920
03-09 11:00:35.714: WARN/InputManagerService(52): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@44cb1428 (uid=10024 pid=685)
03-09 11:00:35.925: WARN/ActivityManager(52): Duplicate finish request for HistoryRecord{44d7a978 com.tesi.Myappname/.Myappname}
That doesn't justify the crash at all. Any suggestions? I really can't understand why I should drive away from the xml-defined layout, and besides that this problem is driving me nuts.
edit
Besides that, I am working offline. I have tried to pass to the browser the string reperesenting HTML of an empty page, and I can't get it to visualize anything. This is really weird.
精彩评论