Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The Asynctask need to get the Context. If your Asynctask is embeded into the activity, just call the java Activity.this as a context. You can also put a context as a field in the Asynctask and then give it as an arg to Asynctask.</p> <p>You can call the Dialog.show in the onPostExecute, it's on UI Thread.</p> <p>This sample AsyncTask is embeded into an activity</p> <p>public class AsyncDialogBuilder extends AsyncTask {</p> <pre><code> private Context context = DriverOnTripActivity.this; private final AlertDialog.Builder dialog = new AlertDialog.Builder(context); private Integer remoteAllWaitinOnCount; public Context getContext() { return context; } public void setContext(Context context) { this.context = context; } @Override protected void onPreExecute() { } @Override protected Integer doInBackground(Integer... integers) { remoteAllWaitinOnCount = User.getRemoteAllWaitinOnCount(latestClosestKojo.getRemoteId()); if (remoteAllWaitinOnCount &gt; 0) { try { makeDialog(); } catch (Exception e) { e.printStackTrace(); } return 100; } else { return 99; } } private void makeDialog() { dialog.setTitle(latestClosestKojo.getName() + " - " + remoteAllWaitinOnCount + " Kojoalas"); dialog.setPositiveButton("S'arreter", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { isDialogPrompted = false; dialogInterface.dismiss(); goToOnBoardingActivity(); } }); dialog.setNegativeButton("Ignorer", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { isDialogPrompted = false; dialogInterface.dismiss(); } }); } @Override protected void onPostExecute(Integer integers) { if (integers &gt;= 100 &amp;&amp; dialog != null) { dialog.show(); isDialogPrompted = true; } } } </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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. 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