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 8128115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:46:21+00:00 2026-06-06T07:46:21+00:00

I am currently developing socket communication between android and server, which is a simple

  • 0

I am currently developing socket communication between android and server, which is a simple java program run in terminal. Things are going well except there is a warning always appears in the logCat when I close the application:

IInputConnectionWrapper    showStatusIcon on inactive InputConnection

I am searching on the internet to find out the problem I found a post in StackOverflow Similar Problem. The difference is that I can send and receive information well in my program. The answer to this similar problem is that connection is not closed. Does that mean I didn’t call socket.close(); after operation? That leads to a more complicated problem of implementation.

First of all, I want a single, static socket to listen and send to a server. Because I might not close the socket every time I transmit something, so I just close it after the listener finishes the work.

Detail codes are posted below

I initialize connection in the constructor as:

client = new Socket(mServerName, mport);
out = new DataOutputStream(client.getOutputStream()); 
inFromServer = new InputStreamReader(client.getInputStream());
reader = new BufferedReader(inFromServer);

And let them be there during the whole process.

I wrote transmitting from android to server into a function as following:

public void sendRequest(int type, int what1, int what2, Object data)
{
    try{
        if(client.isConnected())
        {
            out.writeUTF(encoded(type,what1,what2,data) + "\n");            
        }
    }catch(IOException e){
        Log.e(TAG, "IOException at SendRequest");
        e.printStackTrace();
    }
}

Listener in a new thread:

try {       
        String line = null;
        while ((line = reader.readLine()) != null)
        {
            ReceiveHandler(line);
        }
    } catch (IOException e) {
        Log.e(TAG, "IOException at StartListen");
        e.printStackTrace();
    }finally{
        try { 
         // The Only Place that I close the Socket
            inFromServer.close();
            out.close();
            reader.close();
            client.close();
        } catch (IOException e) {
            Log.e(TAG, "Close Socket with IOException " + e.toString());
            e.printStackTrace();
        } 
    }

My Question is:

Is there something wrong with my implementation or are there better ways to do this?

Thanks so much for your help!

  • 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-06T07:46:22+00:00Added an answer on June 6, 2026 at 7:46 am

    There is a tool that can help you diagnose network related issues both on Android devices and in the emulator. It may help you to track down the issue a bit further. The ARO tool is open source and available here http://developer.att.com/developer/forward.jsp?passedItemId=9700312

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

Sidebar

Related Questions

I am currently developing an android application which requires two devices to communicate over
I'm currently developing a simple multiplayer game app for Android and I need to
I'm currently developping an Android application which connects to a server through TCP. The
I am currently developing a C# socket server that needs to send and receive
I'm currently developing an android application that uses sockets to connect to a local
I am currently developing a program that uses C#'s Dictionary container (specifically, SortedDictionary). This
I'm currently developing on a project which uses some TimerJobs. One of the jobs
Im currently developing a program that uses a scrollable/zoomable image as the main user
I'm currently developing an application which needs a lot of system and process information,
I'm developing an application of multiple socket connections (a TCP alarm watcher). Currently, in

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.