whet i am starting new Activity using this way below
Intent edit = new Intent(getParent(), WebViewLink.class);
TabGroupActivity parentActivity = (TabGroupActivity) getParent();
edit.putExtra(POSITION, FAQ);
parentActivity.startChildActivity("WebViewLink", edit);
I am getting error like this
08-19 13:44:49.955: ERROR/AndroidRuntime(548): Uncaught handler: thread main exiting due to uncaught exception
08-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$2.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)
but when I am using this way for call new Activity There is no problem
Intent edit = new Intent(getParent(), WebViewLink.class);
edit.putExtra(POSITION, FAQ);
More.this.startActivity(edit);
you can see My WebViewLink.java class here
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;
@Override
public 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 onLoadResource(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();
}
}
});
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…