Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>installed</code> is declared only in <code>doInBackground</code>, so it's not visible into <code>onPostExecute</code>. </p> <p>Instead of returning a <code>String</code> in <code>doInBackground</code> (where in fact you always return <code>null</code>), you should return a <code>boolean</code> (which would be <code>installed</code>), and in <code>onPostExecute</code> change the parameter for a <code>boolean</code> and test it instead of testing <code>installed</code>.</p> <p><strong>EDIT</strong></p> <p>Taking more time to update my answer :</p> <p>First, I agree with @codeMagic, you definitely <strong>DON'T</strong> need an <code>AsyncTask</code> to do that !</p> <p>But if you really want to do it this way, here is how you could do it : first, you should change the signature of your <code>AsyncTask</code> this way :</p> <pre><code>class asynctask extends AsyncTask&lt;String, String, Boolean&gt; { </code></pre> <p>Then in <code>doInBackground</code>, change the return value and instead of returning <code>null</code>, return <code>installed</code> :</p> <pre><code>@Override protected boolean doInBackground(String... arg0) { final SharedPreferences settings = getSharedPreferences("pref_name", 0); boolean installed = settings.getBoolean("installed", false); return installed; }}} </code></pre> <p>And finally, change the parameter of <code>onPostExecute</code> to accept a <code>boolean</code> :</p> <pre><code>protected void onPostExecute(boolean installed) { </code></pre> <p>This way, you can test <code>installed</code> in your method.</p>
    singulars
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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