Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving troubles with error in AsyncTask
    text
    copied!<p>I have few problems with syntax errors here. Below I have an <code>alertDialog</code> with <code>sharedPreference</code> and if you are wonder why I have this in a asynctask you can see this <a href="https://stackoverflow.com/questions/18796561/shared-prefence-for-alert-dialog-is-making-my-application-non-responsive">Shared Prefence for alert dialog is making my application non responsive</a> But the syntax problem is underneath <code>installed</code> in my <code>onPostExecute</code> and it says "<code>installed</code> cannot be resovled to a variable." I also have another one under <code>settings</code> in my <code>onPostExecute</code> that says the same thing as well. I know this may seem like an easy fix to some people but I find this really complicated for someone like me. I also advice you look at the link if you have a better method than the <code>AsyncTask</code> and <code>onResume()</code></p> <pre><code>@Override protected void onResume() { class asynctask extends AsyncTask&lt;String, String, String&gt; { @Override protected String doInBackground(String... arg0) { final SharedPreferences settings = getSharedPreferences("pref_name", 0); boolean installed = settings.getBoolean("installed", false); return null; }}} protected void onPostExecute(String file_ad) { if(!installed){ final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("Title"); alertDialog.setIcon(R.drawable.ic_launcher); alertDialog.setAdapter(new MyAdapter(), null); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("installed", true); editor.commit(); } }); alertDialog.show(); } super.onResume(); } </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