When I try to use Async task to execute an HTTP message, I get the following:
ASyncTask: DoInBackground(String...) clashes with DoInBackground(Params...) in Android.os.AsyncTask; attempting to use incompatible return type
How to fix it? This is my first experience using AsyncTask.
The specific line causing the error:
@Override protected String doInBackground(String... params) {
Code from the full AsyncTask:
private class MyTask extends AsyncTask<String, Void, Void> { boolean success = false; @Override protected String doInBackground(String... params) { StringBuilder respData = new StringBuilder(); URL url = new URL("MY_URL"); URLConnection conn = url.openConnection(); HttpURLConnection httpUrlConnection = (HttpURLConnection) conn; httpUrlConnection.setUseCaches(false); httpUrlConnection.setRequestProperty("User-Agent", "App"); httpUrlConnection.setConnectTimeout(30000); httpUrlConnection.setReadTimeout(30000); httpUrlConnection.setRequestMethod("POST"); httpUrlConnection.setDoOutput(true); OutputStream os = httpUrlConnection.getOutputStream();
source share