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

  • Home
  • SEARCH
  • 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 8577819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:14:42+00:00 2026-06-11T20:14:42+00:00

My application has a UI (implemented with an Activity ) and a service (implemented

  • 0

My application has a UI (implemented with an Activity) and a service (implemented with the IntentService). The service is used to send data (synchronous, using NetworkStream.Write) to a remote server as well as to update the transmission status to the UI (implemented using Broadcast Receiver method).

Here is my problem:

  • The application works properly if the size of the buffer used for the NetworkStream.Write is 11 KB or less.

  • However, if the size of the buffer is larger than 11 KB, say 20 KB (this size needed in order to send jpg images), then the sevice keeps working properly (verified with log file), nonetheless the UI its gone (similar as if device’s back button is pushed) and I can’t find the way to bring it back. Its important to point out that in this case the Activity its not going into OnStop() nor OnDestroy() states.

  • At first I thought this would be some ApplicationNotResponding related issue due to a server delay, yet the UI crashes after about 5 sec.

  • Moreover, this only happens with the Hardware version. The emulator version works fine.

    // SEND STREAM:
    
    Byte[] outStream = new Byte[20000];
    // -- Set up TCP connection: --
    TcpClient ClientSock = new TcpClient();
    ClientSock.Connect("myserver.com", 5555);
    NetworkStream serverStream = ClientSock.GetStream();
    serverStream.Write(outStream, 0, outStream.Length);
    serverStream.Flush();
    // . . .
    
    // RECEIVE STREAM:            
    inStream.Initialize();           // Clears any previous value.
    int nBytesRead = 0;
    nBytesRead = serverStream.Read(inStream, 0, 1024);
    
    // -- Closing communications socket: --
    ClientSock.Close(); 
    
  • 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-06-11T20:14:44+00:00Added an answer on June 11, 2026 at 8:14 pm

    One thing first: I would have been commented the question to clarify one thing before I give an answer, but unfortunately I don’t have enough reputation yet.

    The thing I would have asked for is: Why do you need to have a buffer greater than 11k to send an JPG image?

    I nearly do the same in one (async) task with an image of 260k, but with a buffer of 10240 Bytes. Works without difficulties.

    byte[] buffer = new byte[10240];
    for (int length = 0; (length = in.read(buffer)) > 0;) {
      outputStream.write(buffer, 0, length);
      outputStream.flush();
      bytesWritten += length;
      progress = (int) ((double) bytesWritten * 100 / totalBytes);
      publishProgress();
    }
    outputStream.flush(); 
    

    I use this part to read an JPG image from resources or SD and post to my server.

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

Sidebar

Related Questions

So I've implemented an iPad application it has a UISplitView implemented. i'm using the
world! I'm building an application that has to retrieve data from a server in
world! I'm building an application that has to retrieve data from a server in
I see that apple has implemented a max size for the actual application but
The MVC application that I am building has a portion of the page (implemented
My application has one activity which starts two services but does not bind them.
Friend's, I implemented tabhost in my application,i have three tabs defined in my activity
I have an application that runs an activity with a service in a separate
I am making an iphone application which has user information on a web server.
I have an Activity and Service that work together in my application. I've configured

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.