Reputation: 4595
I have set breakpoints in this AsyncTask,
I have put android:debuggable="true"
and I have added android.os.Debug.waitForDebugger();
but still the debugger (Eclipse) would not enter...
class DownloadWebpageTask extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... urls) {
android.os.Debug.waitForDebugger();
try {
Log.e("","Sono in doibacground di DownloadWebpageTask");
return downloadUrl(urls[0]);
} catch (IOException e) {
return null;
}
}
This AsyncTask is called by the following AsyncTask
public class DownloadGelaterieAsyncTask extends AsyncTask<Void, Void, ArrayList<Gelateria>> {
@Override
protected ArrayList<Gelateria> doInBackground(Void... params) {
try {
Log.e("i di doInBackground di DownloadGelaterieAsyncTask", Integer.toString(i));
gelaterie = new DownloadWebpageTask()
.execute( "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=45.4667,9.1833&radius=10000&language=Italian&keyword=gelateria&key=XXXXXXXXXXX"
).get();
} catch (Exception e1) {}
What am I doing wrong?
Upvotes: 0
Views: 63
Reputation: 14274
You're calling an AsyncTask
inside an AsyncTask
. That's not going to work as is. All AsyncTask
s are scheduled on the same thread, so the nested AsyncTask
won't be executed until the first one is done -- you just locked your app.
Just refactor your first AsyncTask
as follows:
public class DownloadGelaterieAsyncTask extends AsyncTask<Void, Void, ArrayList<Gelateria>> {
@Override
protected ArrayList<Gelateria> doInBackground(Void... params) {
try {
Log.e("i di doInBackground di DownloadGelaterieAsyncTask", Integer.toString(i));
gelaterie = downloadUrl( "https://..." );
} catch (Exception e1) {}
There's no need for nesting an AsyncTask
inside an AsyncTask
.
Upvotes: 3