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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:07:03+00:00 2026-06-07T14:07:03+00:00

I am trying to develop a simple chat application, only for study purpose. My

  • 0

I am trying to develop a simple chat application, only for study purpose.
My problem is that when the screen orientation is changing the TCP/IP connection is closed and recreated after orientation changes.

I know that Android destroys the activity and recreates it when changing orientation.

So my question: It is posible to change only view but everything else to remain intact?

Thanks

  • 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-07T14:07:04+00:00Added an answer on June 7, 2026 at 2:07 pm

    Well, the real issue here is that you are performing the TCP/IP connection on the main UI thread, which is a terrible idea because you risk blocking touch events and the layouts from being generated. A NetworkOnMainThreadException is thrown on most new devices these days to prevent this behavior too.

    What I would do is wrap the TCP/IP connection in a Thread, and then have the Thread execute in a worker (non-UI, invisible) Fragment with setRetainInstance(true). This protect your Thread on configuration changes, as the Fragment will remain in memory even when the Activity is destroyed. You can read more about this approach here.

    If the TCP/IP connection needs to exist across multiple Activity instances, you should use a Service instead.

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

Sidebar

Related Questions

I am trying to develop a simple application that polls events from a User's
I'm trying to develop a simple chat application. Here is my chat.js file. var
I am trying to develop a simple python application that does not use a
I am trying to develop a simple application in C# to count the number
Hi I am trying to develop a simple form in extjs, but the problem
I am trying to develop one simple application using Java, Flex and Blazeds. I
I'm learning Objective-C and trying to develop a simple zipper application, but I stopped
I need to develop simple game that will be using peer to peer connection
I'm stuck with a seemingly very simple app that I'm trying to develop Basically,
I am trying to develop a simple database application, I wish to use RMI

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.