Note that there are some explanatory texts on larger screens.

plurals
  1. POBack Button on exit creating a Force Close Error
    primarykey
    data
    text
    <p>I am trying to avoid using onDestroy and want to keep this as simple as possible, but when I exit the program, I get a Force Close error. Not sure why. Here is the code for the main part of the application. Any suggestions?</p> <p><strong>Main Application Code</strong></p> <pre><code> public class Quotes extends Activity implements OnClickListener { ProgressDialog dialog; private WebView webview; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); WebView adsview = (WebView) findViewById(R.id.ads); adsview.getSettings().setJavaScriptEnabled(true); adsview.loadUrl("http://www.dgdevelco.com/quotes/androidad.html"); SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String q = SP.getString("appViewType","http://www.dgdevelco.com/quotes/quotesandroidtxt.html"); String c = SP.getString("appRefreshRate","20"); webview = (WebView) findViewById(R.id.scroll); webview.getSettings().setJavaScriptEnabled(true); webview.setWebViewClient(new QuotesWebView(this)); webview.loadUrl(q); ScheduledExecutorService timer = Executors.newSingleThreadScheduledExecutor(); timer.scheduleAtFixedRate(new Runnable() { @Override public void run() { webview.reload(); } }, 10, Long.parseLong(c),TimeUnit.SECONDS); findViewById(R.id.refresh).setOnClickListener(this); } @Override public void onPause(){ super.onPause(); } @Override public void onResume(){ super.onResume(); } public void onClick(View v){ switch(v.getId()){ case R.id.refresh: webview.reload(); break; } } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu, menu); MenuItem about = menu.getItem(0); about.setIntent(new Intent(this, About.class)); MenuItem preferences = menu.getItem(1); preferences.setIntent(new Intent(this, Preferences.class)); return true; } } </code></pre> <p><strong>LogCat</strong></p> <pre><code> 07-04 13:34:55.011: INFO/DevicePushListener(1415): Connection State Changed: NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true 07-04 13:34:55.011: WARN/WindowManager(1314): Attempted to add application window with unknown token HistoryRecord{40c40f50 com.dge.quotes/.Quotes}. Aborting. 07-04 13:34:55.034: DEBUG/AndroidRuntime(24137): Shutting down VM 07-04 13:34:55.034: WARN/dalvikvm(24137): threadid=1: thread exiting with uncaught exception (group=0x40018560) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): FATAL EXCEPTION: main 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@40517fb0 is not valid; is your activity running? 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at android.view.ViewRoot.setView(ViewRoot.java:527) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at android.view.Window$LocalWindowManager.addView(Window.java:424) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at android.app.Dialog.show(Dialog.java:241) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at android.app.ProgressDialog.show(ProgressDialog.java:107) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at android.app.ProgressDialog.show(ProgressDialog.java:90) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at com.dge.quotes.QuotesWebView.onPageStarted(QuotesWebView.java:22) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:271) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at android.os.Handler.dispatchMessage(Handler.java:99) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at android.os.Looper.loop(Looper.java:123) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at android.app.ActivityThread.main(ActivityThread.java:3806) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at java.lang.reflect.Method.invokeNative(Native Method) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at java.lang.reflect.Method.invoke(Method.java:507) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 07-04 13:34:55.058: ERROR/AndroidRuntime(24137): at dalvik.system.NativeStart.main(Native Method) 07-04 13:34:55.089: WARN/ActivityManager(1314): Force finishing activity com.dge.quotes/.Quotes </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload