- BabyJebus
- Jan 19, 2006
-
|
So I have my first app that I'm building and I've run into a asynctask issue in that I think I need to use it but I don't know just how to do it.
Do something like this...
code:private ProgressDialog progress;
private void doFirstRun() {
SharedPreferences settings = getSharedPreferences("PREFS", MODE_PRIVATE);
if (settings.getBoolean("isFirstRun", true)) {
progress = ProgressDialog.show(this, "First Run", "Creating player database and adding players").show();
new AddPlayersTask().execute();
}
}
private class AddPlayersTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... voids) {
addPlayers();
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("isFirstRun", false);
editor.commit();
return null;
}
@Override
protected void onPostExecute(Void v) {
progress.dismiss();
}
}
|
#
¿
Aug 10, 2012 01:45
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 3, 2024 04:31
|
|