Note that there are some explanatory texts on larger screens.

plurals
  1. PONew Preferences not loading when back button is pressed
    text
    copied!<p>I have this preferences class (below) that saves two ListPreferences, but if the ListPreferences are changed and the back button is pressed, the changes don't take affect unless the application is restarted. Did I miss something? Have been looking everywhere, but just can't seem to find an answer the fits or works. Please help.</p> <pre><code> public class Preferences extends PreferenceActivity { @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); } @Override public void onPause() { super.onPause(); } @Override public void onResume() { super.onResume(); } } </code></pre> <p><strong>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); SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String q = SP.getString("appViewType","http://www.google.com"); 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>
 

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