Issue
I am trying to make a GET
request on a URL, I created a class extending AsyncTask<Void, Void, Void>
and I try to call new MyClass.execute()
... I have done this before and it worked, today it is not working. What am I doing wrong?
Here is my code:
public class SignUpActivity extends AppCompatActivity {
String TAG = SignUpActivity.class.getSimpleName();
String URL;
ArrayList<String> countries = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
new MyClass.execute();
}
private class MyClass extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
//TODO
}
@Override
protected Void doInBackground(Void... params) {
HttpHandler sh = new HttpHandler();
// Making a request to url and getting response
String jsonStr = sh.makeServiceCall(URL, "GET");
//Handling response in jsonStr code
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
//TODO
}
}
Solution
This is a syntax error. It should be
new MyClass().execute();
not as new MyClass.execute();
Answered By - karthik vishnu kumar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.