我正在使用以下方式开始新的活动
Intent edit = new Intent(getParent(), WebVIEwlink.class);TabGroupActivity parentActivity = (TabGroupActivity) getParent();edit.putExtra(position, FAQ);parentActivity.startChildActivity("WebVIEwlink", edit);
我收到这样的错误
08-19 13:44:49.955: ERROR/AndroIDRuntime(548): Uncaught handler: thread main exiting due to uncaught exception08-19 13:44:49.974: ERROR/AndroIDRuntime(548): androID.vIEw.WindowManager$BadTokenException: Unable to add window -- token androID.app.LocalActivityManager$LocalActivityRecord@44dabdc8 is not valID; is your activity running?08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at androID.vIEw.VIEwRoot.setVIEw(VIEwRoot.java:468)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at androID.vIEw.WindowManagerImpl.addVIEw(WindowManagerImpl.java:177)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at androID.vIEw.WindowManagerImpl.addVIEw(WindowManagerImpl.java:91)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at androID.vIEw.Window$LocalWindowManager.addVIEw(Window.java:424)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at androID.app.Dialog.show(Dialog.java:239)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at com.stress.WebVIEwlink.onLoadResource(WebVIEwlink.java:73)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at androID.webkit.CallbackProxy.handleMessage(CallbackProxy.java:355)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at androID.os.Handler.dispatchMessage(Handler.java:99)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at androID.os.Looper.loop(Looper.java:123)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at androID.app.ActivityThread.main(ActivityThread.java:4363)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at java.lang.reflect.Method.invokeNative(Native Method)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at java.lang.reflect.Method.invoke(Method.java:521)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:618)08-19 13:44:49.974: ERROR/AndroIDRuntime(548): at dalvik.system.NativeStart.main(Native Method)
但是当我使用这种方式来调用new Activity时没有问题
Intent edit = new Intent(getParent(), WebVIEwlink.class);edit.putExtra(position, FAQ);More.this.startActivity(edit);
你可以在这里看到我的WebVIEwlink.java类
public class WebVIEwlink extends Activity {public static String position = "position";int position = 0;private button back;private TextVIEw ttl;ProgressDialog myProgressDialog = null;private WebVIEw webVIEw;@OverrIDepublic voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestwindowFeature(Window.FEATURE_NO_Title); getwindow().setFlags(WindowManager.LayoutParams.FLAG_FulLSCREEN, WindowManager.LayoutParams.FLAG_FulLSCREEN); setContentVIEw(R.layout.webvIEw); webVIEw = (WebVIEw) findVIEwByID(R.ID.webvIEw); back = (button) findVIEwByID(R.ID.backtomore); ttl = (TextVIEw) findVIEwByID(R.ID.my_Title); webVIEw.getSettings().setJavaScriptEnabled(true); if (getIntent().getExtras() != null) { if (getIntent().getExtras().containsKey(position)) { position = getIntent().getExtras().getInt(position); } } switch (position) { case More.FAQ: ttl.setText("FAQ"); setWeblink(); webVIEw.loadUrl("file:///androID_asset/faq4.htm"); break; case More.ABOUT_US: ttl.setText("About Us"); setWeblink(); webVIEw.loadUrl("file:///androID_asset/Advice/About Us.HTML"); break; case More.disCLaimMER: ttl.setText("disclaimer"); setWeblink(); webVIEw.loadUrl("file:///androID_asset/Advice/disclaimer.HTML"); break; } back.setonClickListener(new OnClickListener() { public voID onClick(VIEw v) { finish(); } });}private voID setWeblink() { webVIEw.setWebVIEwClIEnt(new WebVIEwClIEnt() { public boolean shouldOverrIDeUrlLoading(WebVIEw vIEw, String url) { vIEw.loadUrl(url); return true; } public voID onl oadResource(WebVIEw vIEw, String url) { if (myProgressDialog == null) { myProgressDialog = new ProgressDialog(WebVIEwlink.this); myProgressDialog.setMessage("Loading.... Please Wait"); myProgressDialog.show(); } } public voID onPageFinished(WebVIEw vIEw, String url) { if (myProgressDialog.isShowing()) { myProgressDialog.dismiss(); } } });}
}
解决方法:
问题出在这行代码中:
myProgressDialog = new ProgressDialog(WebVIEwlink.this);
当你是TabGroupActivity然后子Activity时,需要父母的Context来添加新的windows,Dialogs.试试这种方式:
myProgressDialog = new ProgressDialog(WebVIEwlink.this.getParent());
并为所有对话框执行相同 *** 作.
总结以上是内存溢出为你收集整理的android – 未捕获的处理程序:由于未捕获的异常,线程主要退出全部内容,希望文章能够帮你解决android – 未捕获的处理程序:由于未捕获的异常,线程主要退出所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)