Q:

How do i use OutputStream?

    private byte[] Get(String urlIn) {
        URL url = null;
        String urlStr="http://10.0.0.2:8098";
        if (urlIn!=null)
            urlStr=urlIn;
        try {
            url = new URL(urlStr);
        } catch (MalformedURLException e) {
            e.printStackTrace();
            return null;
        }
        HttpURLConnection urlConnection = null;
        try{
            urlConnection = (HttpURLConnection) url.openConnection();
            InputStream in = new BufferedInputStream(urlConnection.getInputStream());
            byte[] buf=new byte[10*1024];
            int szRead = in.read(buf);
            byte[] bufOut;
            OutputStream outstream = new OutputStream(urlConnection.getOutputStream());
            PrintWriter out = new PrintWriter(outstream);
            out.write("Hello Server!");
            if (szRead==10*1024) {
                throw new AndroidRuntimeException("the returned data is bigger than 10*1024.. we don't handle it..");
            }
            else {
                bufOut = Arrays.copyOf(buf, szRead);
            }
            return bufOut;
        }
        catch (IOException e){
            e.printStackTrace();
            return null;
        }
        finally{
            if (urlConnection!=null)
                urlConnection.disconnect();
        }
    }

First i'm not sure if i added the OutputStream at the right place.
Second i'm getting error on the line:
OutputStream outstream = new OutputStream(urlConnection.getOutputStream());

OutputStream is abstract cannot be instantiated
I also added a thread inside onTouchEvent:
        @Override
        public boolean onTouchEvent(MotionEvent event) {
            float eventX = event.getX();
            float eventY = event.getY();
            float lastdownx = 0;
            float lastdowny = 0;
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    path.moveTo(eventX, eventY);
                    circlePath.addCircle(eventX, eventY, 50, Path.Direction.CW);
                    lastdownx = eventX;
                    lastdowny = eventY;
                    Thread t = new Thread(new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            byte[] response = Get(null);
                            if (response!=null)
                                Logger.getLogger("MainActivity(inside thread)").info(response.toString());   
                        }
                    });
                    t.start();
                    return true;
                case MotionEvent.ACTION_MOVE:
                    path.lineTo(eventX, eventY);
                    break;
                case MotionEvent.ACTION_UP:
                    // nothing to do
                    circlePath.reset();
                    break;
                default:
                    return false;
            }
            // Schedules a repaint.
            invalidate();
            return true;
        }

What i want to do is to send the string "Hello Server!" with a parameter to the server at http://10.0.0.2:8098

A:

First i'm not sure if i added the OutputStream at the right place.

You didn't. You have to send the output before reading the input.

Second i'm getting error on the line:

OutputStream outstream = new OutputStream(urlConnection.getOutputStream());

Should be
OutputStream outstream = urlConnection.getOutputStream();

