Code example for AsyncTask

Methods: execute, executeOnExecutor

0
    @TargetApi(11) 
    public static <T> void executeAsyncTask(AsyncTask<T, ?, ?> task, T... args) {
        // TODO figure out how to subclass abstract and generalized AsyncTask, 
        // then put this there 
        if (AndroidUtils.isHoneycombOrHigher()) { 
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, args);
        } else { 
            task.execute(args);
        } 
    } 
 
    /** 
     * Returns an {@link InputStream} using {@link HttpURLConnection} to connect 
     * to the given URL. 
     */ 
    public static InputStream downloadUrl(String urlString) throws IOException {
        HttpURLConnection conn = buildHttpUrlConnection(urlString);
        conn.connect();
 
        InputStream stream = conn.getInputStream();
        return stream;