There are many topics about this specific issue but nothing is working for me. I have this code:
class MyAsyncTask extends AsyncTask<String, Void, ArrayList<MyObject>> {
private ProgressDialog dialog;
private FragmentActivity context;
public MyAsyncTask(FragmentActivity activity) {
context = activity;
dialog = new ProgressDialog(context);
}
protected void onPreExecute() {
this.dialog.setMessage("...");
this.dialog.show();
}
@Override
protected ArrayList<MyObject> doInBackground(String... params) {
URL url = new URL(params[0]);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
ArrayList<MyObject> objects = null;
try {
InputStream in = connection.getInputStream();
BufferedReader reader = new BufferedReader(
new InputStreamReader(in));
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
return null;
}
String line;
objects = new ArrayList<MyObject>();
MyObject mo = new MyObject();
while ((line = reader.readLine()) != null) {
// Process data
}
reader.close();
} catch (Exception e) {
return null;
} finally {
if (connection != null)
connection.disconnect();
}
return objects;
}
@Override
protected void onPostExecute(ArrayList<MyObject> data) {
if (dialog.isShowing()) {
dialog.dismiss();
}
if (data == null) {
Toast.makeText(context, "fail", Toast.LENGTH_SHORT).show();
}
else {
}
}
}
The problem is that every time when I execute AsyncTask and press back
button on my application, I receive the following warning:
IInputConnectionWrapper showStatusIcon on inactive InputConnection
Because of that when I run my app next time, I can't get input stream from URL. What am I doing wrong?