Hello All,
I've been attempting to build an app to act as a controller for an arduino uno with a wifi shield attached. The app loads but seems to stop and crash on click events.

Code:
package com.gze.bergpreet.abelui;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;

public class RPiui extends Activity {

    public Button button,button2;
    int token=0;
    InetAddress serverAddress;
    int PORT = 1331;
    DatagramSocket socket;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rpiui);


        button =(Button)findViewById(R.id.button);
        button2 =(Button)findViewById(R.id.button2);

        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Perform action on click
                token=1;
                new AsyncMethod().execute();
                token=0;


            }
        });

        button2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Perform action on click
                token=2;
                new AsyncMethod().execute();
                token=0;


            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_rpiui, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    public class AsyncMethod extends AsyncTask<Integer, Integer, Boolean>{

        @Override
        protected Boolean doInBackground(Integer... arg0){
            byte [] ip_bytes = new byte[] {(byte)192,(byte)168,(byte)43,(byte)16};
            try {
                serverAddress = InetAddress.getByAddress(ip_bytes);
            } catch (UnknownHostException e) {
                // TODO Auto-generated catch block

            }

            ByteBuffer outPut = ByteBuffer.allocate(1);
            outPut.putInt(token);
            byte[] outArray = outPut.array();
            DatagramPacket packet = new DatagramPacket(outArray, outArray.length, serverAddress, PORT);
            try {
                socket= new DatagramSocket();
                socket.send(packet);
            } catch (IOException e) {
                // TODO Auto-generated catch block

            }

            return null;
        }
    }
}