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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:09:07+00:00 2026-05-18T08:09:07+00:00

There is something I don’t quite understand right now. My main activity class creates

  • 0

There is something I don’t quite understand right now.

My main activity class creates a Service, which creates a new thread that waits for a TCP connection. Once one comes in, it will start a new activity:

Intent dialogIntent = new Intent(getBaseContext(), VoIPCall.class);
dialogIntent.putExtra("inetAddress", clientSocket.getInetAddress());
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(dialogIntent);

After that, the onCreate() method of that class gets run. It will create 2 threads: one records and send data, the other one receive and plays data. Those threads have a forever while loop.

For some reason, I notice that the onCreate() of that last class gets called again, which makes my program crash. I do not understand why it is called again as only the 2 threads are running, there is no user interaction. The documentation says: “Called when the activity is first created.”. The activity is already running and I am not trying to create it.

Could someone please explain me this behavior?

  • 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-05-18T08:09:07+00:00Added an answer on May 18, 2026 at 8:09 am

    Android will recreate your activity after certain “device configuration changes”. One such example is orientation. You can read more here…
    http://developer.android.com/guide/topics/resources/runtime-changes.html

    Perhaps something in your threads is doing something which is considered a configuration change?

    If that’s the case you might find it useful to extend the Application class instead and do your initialization there. See this post…
    Activity restart on rotation Android

    HTH

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

Sidebar

Related Questions

I am writing a django application and there is something I don't know how
I'm trying to create a staging branch on Heroku, but there's something I don't
I'm using Automake to maintain the package, there are some shell scripts which don't
Is there something like ISNULL() OR COALESCE() but not that checks for null value
Is there something like anonymous inner classes (used in Java) in C#? I explain
How do I hook up my viewcontroller to the TabBarController? Is there something I
I want to group RadioButtons, but I don't want to use the visible control
When storing a bunch of items and I don't need random access to the
I was wondering, why can't there be a void data type that is not
Ok, I am an experienced web developer but sometimes ASP.Net is tricking me. I

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.