Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7684299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:59:40+00:00 2026-05-31T18:59:40+00:00

My aim is to have a picture drawn on one device to be duplicated

  • 0

My aim is to have a picture drawn on one device to be duplicated onto another, I have managed to send the coordinates of the path to a networking thread but am unable to handle these on the second device. how would i draw a path on the second device using coordinates from the stream in as real time as possible. Currently i have a threaded connection:

public class connecting implements Runnable{

    Socket sock;
    ObjectInputStream ois;

    @Override
    public void run() {

        try{
            sock = new Socket("10.42.34.46", 1337);         
            InputStream is = sock.getInputStream();
            ois = new ObjectInputStream(new BufferedInputStream(is));


        }catch(IOException ex){
            ex.printStackTrace();
        }

        while(true){
            com.DrawTastic.Drawring serverDraw = null;

            serverDraw =   (com.DrawTastic.Drawring) ois.readObject();

            float mX =  serverDraw.getMx();
            float mY = serverDraw.getMy();


        }
    }

}

how would i get the float variables to continuously draw into this onDraw method in another thread

@Override
    public void onDraw(Canvas canvas) {

        connecting ncoords = new connecting();
        mPath.lineTo(mX, mY);

        canvas.drawPath(mPath, mPaint);
        canvas.drawColor(Color.WHITE);

        canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
        canvas.drawPath(mPath, mPaint);
    }
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:59:41+00:00Added an answer on May 31, 2026 at 6:59 pm

    This is the most basic tutorial about client/server programming in Java. Let’s start with naming

    • client is the device interacting with real touch events
    • server device is listening to events brought in by the client

    The client implements onTouchEvent(MotionEvent) and writes x and y coordinates to its socket’s OutputStream. Even if you want it as realtime as possible, you may need to store the events (x, y and timestamp) locally and transmit them at certain time intervals. Like every other blocking operation, this will run on a separate thread than the main application thread. This is a pseudo implementation

    ClientActivity
      thread:
        while activity_is_running:
          sleep 100
          socket.write list_of_events
    
      onCreate(): start_background_thread
      onViewTouched(): thread.add_event
    

    The server will have a ServerSocket listening for events. Every time an event is received it will draw. Note that in order to access the drawing thread from the background thread which the socket is listening on, you may use a Handler. A Handler is simply a way to run some code on a specific thread. You only need to declare a Handler instance variable for your ServerActivity and instantiate it in onCreate: this way the Handler will be bound to the application main thread, which is also the UI thread.

    ServerActivity
      thread:
        while activity_is_running:
          handler.draw socket.get_event_from_input_stream
    
      onCreate():
        handler: new Handler()
        start_background_thread
    

    The last part is how to remember already drawn things, both on the client and on the server side. This is because each call to onDraw will give you a clean bitmap, so you must either store each event in a list and draw from that list, or you can keep a cache of already drawn things (see this paste)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My ultimate aim is to have a table that looks like this: Maturity Band
Here is my page: http://budclarychevy.com/custom/parts-specials-test My aim is to have the images clickable and
Aim The aim is to a have a container DIV with a fixed height
I have such a grid square disk. Every grid represents a pixel. My aim
Suppose that I have n points (x,y1),(x2,y2),.....(xn,yn) my aim is to connect these points
My ultimate aim is to have an inline div on my page which horizontally
I have this kind of path architecture : >main_path/ __init__.py config/ __init__.py common.py app_1/
I have problem in creating modular analysis architecture for C# application. Aim: It is
My aim is have the text inside this div displaying in the middle of
Aim: To have the if statement execute a onclick event through code. I currently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.