2つのint値を取得するAsynctaskがあり、それらをonPostExecuteに渡して、ビューに表示したいと思います。
これが私のコードです:
public class QueryServer extends AsyncTask <String, Void, Integer> {
protected Integer 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");
return Onlineplayers;
}
protected void onPostExecute(Integer Onlineplayers){
TextView onlinePlayersView = (TextView) findViewById(R.id.online_players);
onlinePlayersView.setText(""+Onlineplayers+"/"+ Maxplayers); //i need to pass Maxplayers to use it here
}
前もって感謝します。