0

I want to create custom events in my server code. Like onMessageReceive() , onServerStarted() etc , My Server Code is :

Thread thread = new Thread(new Runnable() {
            public void run() {
                 try {
                    String text;
                    DatagramPacket p1 = new DatagramPacket(message, message.length);
                    DatagramSocket s1;
                    try {
                        s1 = new DatagramSocket(server_port);

                        Log.d("UDP Server","Listening");
                        s1.receive(p1);
                        text = new String(message, 0, p1.getLength());  
                        Log.d("Client Message",text);

                        stop(s1);   
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                 } catch (Exception e) {
                 }
            }
        });
        thread.start();

How can I do it ? BY using CallBacks ? Ineed help in this

Hammad Shahid
  • 2,216
  • 5
  • 32
  • 60

1 Answers1

1

I think you need a public interface inside of your class.

Check this link: http://www.codexperience.co.za/post/android-pie-chart-part-3.-implementing-callback-methods-on-custom-view

This is a custom pie chart view tutorial. Its similar to your situation in that it involves threads and callback methods.