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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:05:40+00:00 2026-06-14T02:05:40+00:00

I have a method like this in my class which extends Activity @Override public

  • 0

I have a method like this in my class which extends Activity

@Override
public void onDestroy() {
    Log.i("onDestory: ", "Inside OnDestory!");
    bluetoothCommunicator.destroyedApp();
    super.onDestroy(); 
}

The method destroyedApp() look like this:

public void destroyedApp() {
        if(server != null)
            server.destroy();   
}

Where server is an Instance of a class which extends Thread

Here is the scenario:

I’m opening the application for the first time, inside my onCreate method, I create a new instance of the bluetooth class which sets up the BluetoothServerSocket, this works fine and I’m able to transfer files to my phone.

This also works when I have my application in the background, because the thread is still alive.

But

When I’m killing the application, according to the Activity Life Cycle

Activity Life Cycle here

The onDestroy() method should be called by the Android Framework. And when I’m launching the application once more, the onCreate method should be called, but it doesnt seems that an instance of the BluetoothServerSocket is being created. I have no LogCat info, because the device which sends the bluetooth file, only says:

Error Log:
Write Error: 
Transport endpoint is not connected
__obex_connect:
error=-2
Unable to connect to the server
Error

Which tells me that the BluetoothServerSocket is not "alive"

Any suggestion on how I can accomplish this?

  • 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-14T02:05:42+00:00Added an answer on June 14, 2026 at 2:05 am

    There is generally no guarantee that the onDestroy() method will be called at all. According to the docs:

    Note: do not count on this method being called as a place for saving data! For example, if an activity is editing data in a content provider, those edits should be committed in either onPause() or onSaveInstanceState(Bundle), not here. This method is usually implemented to free resources like threads that are associated with an activity, so that a destroyed activity does not leave such things around while the rest of its application is still running. There are situations where the system will simply kill the activity’s hosting process without calling this method (or any others) in it, so it should not be used to do things that are intended to remain around after the process goes away.

    Derived classes must call through to the super class’s implementation of this method. If they do not, an exception will be thrown.

    So I would first test if it is being called reliably.

    Also, you are callling super.onStop() in your onDestroy(). It should be super.onDestroy()

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

Sidebar

Related Questions

I have a proxied method in a MongoRepository extender class like this: public interface
If I have a method like this: public void DoSomething(int Count, string[] Lines) {
I have a one android class which extends Activity. public class MainAct extends Activity{
I have a method like this, public List<T> Test<T>() { // do something. }
I have a method like this: public IOrganizationService GetConnection(bool multi) { if(!multi) { Parallel.For(0,
i have a method like this: public JObject Get(int id) { return new JObject(new
I have a web method like this as part of a web service public
(I have got class MainActivity (extends Activity) and there I have got method setContentView(GameView);
I have custom db class which extends MySQLi class MySQLi->query() method returns obejct with
I have two classes which extend Activity and need to call another class method

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.