Look at code snippet below from my SetupActivity – how can I test that the task I fired here actually executed correctly?
For example this line:
new AttachChildGcmTask(app).execute(app.getChildInfo().getId());
Code snippet from my Activity:
....
@Override
public void onClick(View v) {
if (v.getId() == R.id.btn_proceed) {
finishSetup();
}
}
private void finishSetup() {
UIUtilities.showToast(this, R.string.setup_completed, true);
final AppBipper app = (AppBipper) getApplication();
app.setSetupCompleted(true);
Log.i(TAG, "finishSetup childId: "+app.getChildInfo().getId());
new AttachChildGcmTask(app).execute(app.getChildInfo().getId());
Log.i(TAG, "download settings");
new FetchClientSettings(app).execute();
Log.i(TAG, "cancel all scheduled alarms");
ScheduledLocationsHelper helper =
ScheduledLocationsHelper.getInstance(app.getDBManager(), app);
helper.cancelAlarms();
startActivity(new Intent(this, StartupActivity.class));
finish();
}
I guess you mean that the activity dies before the tasks are completed.
So include those tests inside your
AsyncTaskclass and have them report to your UI somehow (Broadcasting an intent, using an handler and so on…)