Code example for AsyncTask

Methods: execute

0
	@SuppressLint("NewApi") 
	public static <P, T extends AsyncTask<P, ?, ?>> void execute(T task, P... params) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
		} else { 
			task.execute(params);
		} 
	} 
 
	public static boolean isFroyo() { 
		return Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO;
	} 
 
	public static void getAndSaveToFile(URL url, File file) throws IOException {
		InputStream is = null;
		FileOutputStream fos = null;
 
		try { 
			HttpURLConnection c = (HttpURLConnection) url.openConnection();
			c.setRequestMethod("GET");
			c.connect();