Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy receiving pictures in packets

    Hello guys! i'm Russell and i need help on my android programming.
    i'm using TCP and my android device is the client side. i am trying to transfer a picture over from my com to the android device and i keep getting errors.
    on the computer i have a program that breaks up the image into bytes and sends it in packets . (yes i need to send it in packets. i need to do it that way. sadly haha)

    ok here is my code

    private void receivingImage(Message msg){


    String value = msg.getData().getString("Sent Message");
    byte[] readBuf = (byte[]) msg.obj;

    receivedPacketCount++;
    int messageLength = 0;

    byte[] toSave = null;

    if(msg.arg1 < sendTotalLength){

    toSave = new byte[msg.arg1 - 4];

    for(int i = 0 ; i < msg.arg1 - 4; i++){

    toSave[i] = readBuf[i];

    }
    messageLength = msg.arg1;

    }
    else{


    toSave = new byte[sendDataLength];

    for(int i = 0 ; i < sendDataLength; i++){

    toSave[i] = readBuf[i];

    }
    messageLength = sendTotalLength;
    }

    byte[] countByte = new byte[4];

    String value1 = "";

    //to convert from little endian to big endian format - working on HTC Desire
    for(int i=0; i < 4; i++){
    Log.d("Count value", "i : " + i + " : msg - " + readBuf[messageLength-i-1]);
    countByte[i] = readBuf[messageLength-i-1];
    value1 += readBuf[messageLength-i-1];

    }

    int packCount = readIntFromByteArray(countByte);

    Log.d(TAG, "message ("+toSave.length+") - : " + packCount + " : " + value1);

    try{
    data.set(packCount, toSave);
    }
    catch(Exception e){

    Log.d(TAG, "error message : " + e.getMessage());

    }

    requestForNextPortion(packCount+1);

    }



    help needed thanks a bunch

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,732
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names.

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    lol :/ i'm such an idiot :/ sorry haha!
    where do i post the java cause i dont think there are any "java" fourms here

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,732
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Quote Originally Posted by Raskyl View Post
    lol :/ i'm such an idiot :/ sorry haha!
    where do i post the java cause i dont think there are any "java" fourms here
    Try the Java and JSP forum. Ask Moderator Fou-Lu to move the thread over - don't just repost.

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    OK, I've moved the Thread into the Java Forum
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •