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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:56:35+00:00 2026-06-09T09:56:35+00:00

My application starts with creating MyApplication extends Application I have service that runs on

  • 0

My application starts with creating MyApplication extends Application

I have service that runs on background by alarm and when service done running (obtaining GPS position) I start AsyncTask from that service to do sync with my server.

Here is my understanding:

  1. Only one Application can run at a time in Android OS. I’m talking about instance of MY application. So, there is no way I can have 2 instances of my Application object from the same package running.
  2. If I see messages I log inside Application.onCreate() that means that OS shut down my Application.
  3. Service runs on UI thread even though not visible.
  4. If I spawn AsyncTask from my service and OS kills my application – AsyncTask get’s terminated as well. There is no way I can control graceful termination of my AsyncTask.
  5. If I had Alarm scheduled and Application was down – OS will send broadcast which will in turn start Application and then service.
  6. Alarm starts service every 5 minutes. Service tries to obtain location for UP TO 1 minute and starts AsyncTask when done. So, my AsyncTask have 4 minutes before next service start. Inside Async task I do DB access and this causing issues like listed below..

Is my understanding correct? Reason I’m asking this because I write logs from all the devices that run application and sometimes observe weird behaviors. Most devices run Application almost 24/7 but on some I see Application_Start logged event all the time.

Is there any way to simulate Application shutdown by system for my testing? Is what I’m doing wrong and need to be done differently? I’d like to syncronize my background processing because there is a lot of data read/write and it is blocking..

java.lang.RuntimeException: An error occured while executing doInBackground()
 at android.os.AsyncTask$3.done(AsyncTask.java:299)
 at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
 at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
 at java.util.concurrent.FutureTask.run(FutureTask.java:137)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
 at java.lang.Thread.run(Thread.java:856)
Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (code 14)
 at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(Native Method)
 at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:838)
 at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:836)
 at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
 at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:143)
 at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133)
 at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:196)
 at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:236)
 at com.idatt.data.LockData.Lock(LockData.java:37)
 at com.idatt.common.AsyncProcessor.doInBackground(AsyncProcessor.java:154)
 at com.idatt.common.AsyncProcessor.doInBackground(AsyncProcessor.java:18)
 at android.os.AsyncTask$2.call(AsyncTask.java:287)
 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
 ... 4 more
android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (code 14)
 at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(Native Method)
 at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:838)
 at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:836)
 at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
 at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:143)
 at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133)
 at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:196)
 at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:236)
 at com.idatt.data.LockData.Lock(LockData.java:37)
 at com.idatt.common.AsyncProcessor.doInBackground(AsyncProcessor.java:154)
 at com.idatt.common.AsyncProcessor.doInBackground(AsyncProcessor.java:18)
 at android.os.AsyncTask$2.call(AsyncTask.java:287)
 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
 at java.util.concurrent.FutureTask.run(FutureTask.java:137)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
 at java.lang.Thread.run(Thread.java:856)
  • 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-09T09:56:38+00:00Added an answer on June 9, 2026 at 9:56 am
    1. wrong . android really can run multiple processes and threads (and apps) at the same time . it does it all the time , though it usually gives the foreground app more CPU than the rest . also , even though i’ve never done it , it’s possible to run multiple instances of your own app and use multiple processes.

      however , if your app shouldn’t use CPU while not in the foreground (like a game, for example) , please try to do so . nobody wants to have an app that drains the battery while it’s not even seem to be running.

    2. very wrong . onCreate of the app occurs at the beginning . if it occurs multiple times, it means that it was restarted (either by the OS or by the user).

    3. correct . for background work , use a worker thread.

    4. depends . if you have the service started as a foreground service (with a notification) , the OS will give the killing of the service a very low priority .

    5. depends on what your app does . if it does it , it will occur this way .

    6. when you create a background service , you have to remember that the OS is allowed to close it whenever it thinks it doesn’t do an important task . that’s why you have to be able to resume your work when such a thing occurs .

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

Sidebar

Related Questions

I have couple resource DLLs that I currently load when application starts using following
It seems that when a WPF application starts, nothing has focus. This is really
I've written a Autoit script that starts a GUI application, when the application starts
I'm compressing some textures using ETC1 when my application starts. I also have a
I'm creating three threads in one of my application. The requirement I have is
I have shifts in my application. I want to restrict the time that a
I am creating one application related to BroadcastReceiver and Service . My intention is
I am creating multiple tabs dynamically when my application starts up. Put it this
I have an MFC application (using a legacy library that I can't change). When
I'm creating a series of webservices for my application and i have the need

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.