android - Pass a parent activity object into AsyncTask -
i want pass parent activity called asynctask asynctask..
below part of code want use activity object in doinbackground parameters instead of string cant because ab unable it.. please explain how it..
public class backgroundtask extends asynctask<string, void, string> { alertdialog alertdialog; alertdialog alertdialog2; context ctx; userlocalstore userlocalstore; string res_name , res_username , res_dob , res_email , res_id , res_pass; backgroundtask(context ctx) { this.ctx =ctx; } @override protected void onpreexecute() { alertdialog = new alertdialog.builder(ctx).create(); alertdialog.settitle("login information...."); alertdialog2 = new alertdialog.builder(ctx).create(); alertdialog2.settitle("apologies"); } @override protected string doinbackground(string... params) { string reg_url = "http://8miles.freeiz.com/register.php"; string login_url = "http://8miles.freeiz.com/getuserinfo.php"; string method = params[0]; if (method.equals("register")) { string name = params[1]; string user_name = params[2]; string user_pass = params[3]; string email = params[4]; string dob = params[5];
is backgroundtask
inner class inside activity
? if so, wont need pass context
parameter. instead, can use *activityname*.this
.
that aside, method looks fine. may want make constructor public
.
Comments
Post a Comment