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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:29:31+00:00 2026-06-06T06:29:31+00:00

Unfortunately, I have to use a C library with internal state in my Android

  • 0

Unfortunately, I have to use a C library with internal state in my Android project. The library includes state-maintaining functions init() and release(). I have written a wrapper class with static init() and release() members. Then I added calls to these methods in main activity’s OnCreate() and OnDestroy() respectively.

And that is where I got a problem. When the system is low on memory and some other activity is in foreground, main activity gets killed and release() is called. Therefore, all subsequent calls to native library fail spectacularly.

The question is, how to ensure main activity is never killed? Or perhaps there is a better way to call the native functions than doing it in the activity’s callbacks?

  • 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-06T06:29:34+00:00Added an answer on June 6, 2026 at 6:29 am

    Maybe you should have a look at the Application class. You can override it and declare your custom Application class in your Manifest. Do the initialisation on the onCreate() of your Application class.

    I am not sure what your library acutally does, maybe you can elaborate, and depending on your needs you can also consider running a Service which will be less likely to be killed by Android than your Activity.

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

Sidebar

Related Questions

I have to use an extern library providing lots of free functions that do
I want to use the ASSIMP library http://assimp.sourceforge.net in an iOS project. Unfortunately, I'm
I have a static library Xcode 4 project that includes a home-brewed rendering engine,
I wanted to use monotouch, but unfortunately I don't have $400 to spend. So
I'm trying to use eclipse encoding UTF-8, for polish characters. Unfortunately, I still have
I use v-usb library for my project. I wrote code and i want compile
I'm currently writing a wrapper library for windows mobile in C/C++. I have to
I have to use a function from a shared library which leaks some small
I'm attempting to use the Twitter API with the DotNetOpenAuth library. I have a
I'm attempting to use the DecimalMin validator from NHibernates Validator library. Unfortunately, due to

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.