i'm pretty new in programming android Apps actually this is my first, so sorry for my (maybe simple) question.
All i want to do is to post some values by httprequest on a website (this works fine so far) and get a message back, if it was success full (there's the problem). So my class MainActivity looks like this:
public class MainActivity extends Activity implements OnClickListener {
private Button sendButton;
private Button graficButton;
[...]
@Override
public void onClick(View v) {
[...]
new ExecutePost().execute(zusammen);
return;
}
public void checkResponse(Integer responseCode) {
if(responseCode == 200){
new AlertDialog.Builder(this)
.setMessage(R.string.response_ok)
.setNeutralButton(R.string.error_ok, null)
.show();
return;
}else{
new AlertDialog.Builder(this)
.setMessage(R.string.response_false)
.setNeutralButton(R.string.error_ok, null)
.show();
return;
}
}
In class ExecutePost I try to call the function checkResponse from the MainActivity class but there i get the Compiler Error:
No enclosing instance of the type MainActivity is accessible in scope
This is how i coded the class ExecutePost:
public class ExecutePost extends AsyncTask<String, Void, HttpResponse>{
private IOException exception;
private ClientProtocolException clientException;
@Override
public HttpResponse doInBackground(String... alles) {
works fine
}
@Override
protected void onPostExecute(HttpResponse resRes) {
Integer code = resRes.getStatusLine().getStatusCode();
super.onPostExecute(resRes);
MainActivity.this.checkResponse(code);
}
}
I get the error message in the last line for *MainActivity.this.*checkResponse(code); I guess it has something to do with instances / static non-statics methods and so one...
Thanks in advance. Timo