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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:33:05+00:00 2026-06-09T23:33:05+00:00

Hello I have a little chat application, which bind to my service who creates

  • 0

Hello I have a little chat application, which bind to my service who creates a tcp/ip connection with my server.
I use aidl btw.

My problem is that I don’t know to handle screen orientation especially on destroy method.

I would like that my service to be online all the time and I don’t want to stop it when application destroys.

For now I have on “onDestroy” method unbindService(conn) to resolve the “leaked connection problem”.

After activity is destroyed when is recreated it freeze.
Thank you, and here are some code snippets.

serviceIntent = new Intent(getApplicationContext(),ChatService.class);
    boolean result = bindService(serviceIntent, conn,Context.BIND_AUTO_CREATE);
    startService(new Intent(getApplicationContext(),ChatService.class));
    Log.d(TAG, "Service binded");

@Override
protected void onDestroy() {
    Log.d(TAG, "ON DESTROY");
    unbindService(conn);
    super.onDestroy();
}
  • 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-09T23:33:05+00:00Added an answer on June 9, 2026 at 11:33 pm

    Service does not have UIs, therefore you may say that this does not depends on your service, but your activity. Return START_STICKY in onStartCommand() which tells you that it has to be running even when you unbind from it, basically you can bind/unbind any time to the persistent (not persistent until android OS decides to kill it) running service.

    In your activity override onConfigurationChange() method and do nothing in it, then in your manifest use android:configChanges="orientation".

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

Sidebar

Related Questions

I am adapting a little rmi client-server application. I have written several things :
Hello I have a small function which I use for searching for a users
Hello folkes I have this little problem for which I cannot find a suitable
I have this little text <div> Hello world<br> this is a good<br> text! <br><br>
Hello I have next function, what always return null as result, but service calling
hello I have my code that connects to my ftp server $conn_id = ftp_connect($ftp_server);
Hello I have a little problem with requests : In an action executeFiche, I
i have a little problem about preg_match_all and str_replace <? $source = 'hello @user_name,
Hello! I have a little problem I was hoping the community could help me
Let's say I have this little piece of code: <?php $tmp = str_split('hello world!',2);

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.