android - Calling the old method call inside AsynTask doInBackground -
android - Calling the old method call inside AsynTask doInBackground -
i'm new android programming , coded app in android 2.2. when tried run app in android 3 or higher error :
android.os.networkonmainthreadexception
in android 2.2 have method this:
public jsonobject makeservicecall(string url, map<string, string> params)
which performing network phone call operations. looking google found need move code asynctask
class of doinbackground
.
but have problem in changing params of doinbackground
takes object...
varags, method takes 2 parameter string,map<string,string>
.
are there work around can within doinbackground
phone call original makeservicecall
.
thanks in advance.
you can utilize constructor of custom asynctask
send multiple variable, don't need send variable in execute()
method. this:
private class myasynctask extends asynctask<void, void, boolean>{ private string mstring = null; map<string, string> mmap; public myasynctask(string s, map<string, string> map) { //assign values class fields this.mmap= map; this.mstring = s; } @override protected boolean doinbackground(void... params) { //access class fields here. } }
use below in other activity or other class:
new myasynctask(yourstring, yourmap).execute();
android
Comments
Post a Comment