New Getpostask ("getgrouppos.php"). Execute ();//Start asynchronous class with PHP name in parentheses
public class Getpostask extends Asynctask<void, Void, list<info>> {//info is a custom class string Url;public Getpostask (String URL) {//get PHP filename this.url=url;} Protected list<info> doinbackground (Void ... params) {//Auto execute jsonobject jsonobject = null;//transfer parameters to php file list< basicnamevaluepair> list = new arraylist<basicnamevaluepair> (), List.add (New Basicnamevaluepair ("GroupID", GroupID)); try {jsonobject = mynetutil.sendgetrequest (constants.baseurl + url,//start list); if (jsonobject! = null) { Jsonarray Jsonarray = Jsonobject.getjsonarray ("Grouppos"),//json array to match the inside of the PHP file for (int i = 0; I <= jsonarray.length () ; i++) {Jsonobject JsonObject1 = (jsonobject) jsonarray.get (i); String Objecticon = jsonobject1.getstring ("Objecticon"); String ObjectID = jsonobject1.getstring ("ObjectID"); String objectName = jsonobject1.getstring ("ObjectName"); String objectaddress = jsonobject1.getstring ("objaddress"); String Objectcompany = jsonobject1.getstring ("Objectcompany");d ouble Infolat = jsonobject1.getdoUble ("Infolat");d ouble infolng = jsonobject1.getdouble ("infolng"), Info_all.add (new info (R.DRAWABLE.A01, R.drawable.maker,objectid, ObjectName, Objectaddress,objectcompany, Infolat, INFOLNG));}} catch (Exception e) {e.printstacktrace ();} return info_all;} @Overrideprotected void OnPostExecute (list<info> result) {//Then executes this part after execution of the above, result is the return value above Info_ Allsuper.onpostexecute (result);//write down what to do after getting the data from the Cloud Database}}
Android connection Baidu Cloud database Demo