您可以定义一个Wrapper类,其中包含两个整数:
public class Wrapper{ public int onlinePlayers; public int maxPlayers;}
并用它代替
Integer:
public class QueryServer extends AsyncTask<String, Void, Wrapper> { protected Wrapper doInBackground(String... serverAddress) { Log.d("QueryServer", ""+serverAddress[0]); MCQuery mcQuery = new MCQuery("" + serverAddress[0] ,25565); QueryResponse response = mcQuery.basicStat(); int onlinePlayers = response.getonlinePlayers(); //first vaule int maxPlayers = response.getMaxPlayers(); //second vaule Log.d("MCQuery", "" + onlinePlayers + " onlinePlayers"); Wrapper w = new Wrapper(); w.onlinePlayers = onlinePlayers; w.maxPlayers = maxPlayers; return w; } protected void onPostExecute(Wrapper w){ TextView onlinePlayersView = (TextView) findViewById(R.id.online_players); onlinePlayersView.setText(""+w.onlinePlayers+"/"+ w.maxPlayers); //i need to pass Maxplayers to use it here }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)