public class BackgroundTask extends AsyncTask<MyTaskParams,Void,String> {
Context context;
public BackgroundTask(Context context) {
this.context = context;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(MyTaskParams... params) {
String method = params[0].method;
if(method.equals("Register")) {
String username = params[0].username;
String password = params[0].password;
String email = params[0].email;
String gender = params[0].gender;
int age = params[0].age;
String country = params[0].country;
int daily_goal = params[0].daily_goal;
Log.d("MyApp", "**** Information ***** \n" + username + "\n" + password + "\n" + email + "\n" + gender + "\n" + age + "\n" + country + "\n" + daily_goal);
}
}
}
Remember that, this is just an example of AsyncTask with multiple parameters. You need to transform these code segments on your own code :)
Tip : You should not forget while you are using extra pojo for AsyncTask, your params object contains each value inside so you need to get all with “params[0]”.. Do not confuse with : params[0],params[1] for each value. You just need to use params[0].valuename that’s all :)