Im trying to make a single UDP app in android studio. Whenever I run the 
app and press the button the app crashes. 
Im using Datagram object to make it. My code seems to be alright but I 
donĀ“t know where the mistake is. ITS DRIVING ME CRAZY please, help me. 


This is the main activity page : 



 package lumma.e_motionvrplayer;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class MainActivity extends AppCompatActivity {

    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    private GoogleApiClient client;

    //Cierre de la clase
    @Override

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // ATTENTION: This was auto-generated to implement the App Indexing 
API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client = new 
GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
    }

    public void clickplay(View v) throws IOException {

        try
        {
            DatagramSocket socket = new DatagramSocket();
            byte[] buf = new byte[256];
            String messg = "play";

            buf = messg.getBytes ();
            InetAddress address = InetAddress.getByName ("255.255.255.255");
            DatagramPacket packet = new DatagramPacket(buf, buf.length, 
address, 5000);
            socket.send(packet);
        }
        catch (IOException e)
        {
        }
    }
    public void clickrestart(View v) throws IOException {
    }

    public void clickpause(View v) throws IOException {
    }
    public void clicknext(View v) throws IOException {
        }
    public void clickprev(View v) throws IOException {
        }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/82d271ec-a758-4067-ac38-6b241d9a6366%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to