package de.android.test3;
import java.io.BufferedReader;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
-
import android.app.Activity;
import android.content.Context;
import android.location.Criteria;
public class NextActivity extends Activity {
private static final String TAG = "NextActivity";
private String myCookie;
+ private static final int tasksMax = 10;
+ //There will never be more than 10 threads at the same moment. New tasks will wait in a queue
+ //for available threads in this pool in case of more than tasksMax tasks at the same moment.
+ private final ExecutorService exec = Executors.newFixedThreadPool(tasksMax);
/** Called when the activity is first created. */
@Override
public void makeUseOfNewLocation(Location location) {
final MobieAdHttpClient webServiceConnection;
- final ExecutorService exec = Executors.newSingleThreadExecutor();
String latitude = Double.toString(location.getLatitude());
String longitude = Double.toString(location.getLongitude());
Log.e(TAG, "Error while creating a URL", e);
}
webServiceConnection = new MobieAdHttpClient(this.myCookie, url);
- exec.execute(webServiceConnection);
+ this.exec.execute(webServiceConnection);
}