I'm quite new to Android world and I have been developing an Android application with Phonegap (Jquery) that communicates with a Background Service (Java) that reports GPS location every 10 secs. The memory consumption is usually around 30MB, not that much, however I have perceived that Android, for some reason, kills my application after a while, probably because it needs more memory.
So, Is there a way of avoiding that? If not, how can I detect when the application is being killed?
If your app is getting killed by the OS due to normal usage memory pressure, there is no way to avoid that as that is what the OS was designed to do with backgrounded apps.
You will have to find a way to recover gracefully but your webapp is starting as if it was newly launched.
As an alternative you can convert your app to a native app. While the same thing is happening with a native app, its happening much quicker as all of the UI elements are native UI elements (buttons, text fields, etc.) while in a webapp you are injecting HTML and JavaScript into a WebView and depending on the Webkit engine to render everything. Should you go the native route, the documentation and tutorials available at Android Developer site are available.
Related
I'm currently developing and maintaining an Android Legacy app, native in Java. The App has been growing slowly throughout the years and I think the original architecture design it falling a bit short.
The app opens the native android camera, and for some reason, it kills the process in background, perhaps due to lack of resources. I've tested different flows with the android profiler, and wasted a lot of time trying to pinpoint what its happening. The flow goes as this:
The app is filled with data, using a SQL DB and static variables, then at some point the user is required to use the native camera to retrive a photo, then return to the app and keep on with the process. Sometimes, the process dies while being in the native camera app, and when returning, all the data stored on the static variables are empty, thus crashing the app and restarting itself.
Using the Android Studio Profiler, I found that when the process dies, it prints this in the console:
2021-11-18 22:19:54.906 9177-9762/es.myapp I/PhenotypeProcessReaper: Memory state is: 400
2021-11-18 22:19:54.906 9177-9762/es.myapp I/PhenotypeProcessReaper: Killing process to refresh experiment configuration
2021-11-18 22:19:54.906 9177-9762/es.myapp I/Process: Sending signal. PID: 9177 SIG: 9
Does anyone has any idea of what is happening? What is PhenotypeProcessReaper?
I'm trying to write a class to save the states of all the data to be able to recover the app after the process, but in the mean time I would really appreciate some help. Thanks!
My android java app has Offline Video feature like the YouTube app. I do not use android.app.DownloadManager because it does not support pausing the downloads(or as I know).
I have been using a third party download manager library(tonyodev.fetch2) and it does the work done but the problems are:
How can I make the download independent of the app closing/opening etc and also being able to control it when required from an Activity.
If I use a Service for the above problem, what do I use, IntentService or just normal Service keeping in mind I have to know about the ongoing downloads and control it(pause/stop/resume) from any activity.
I have been using android worker class which extents ListenableWorker but I cant seem to make things work as required.
I have been struggling with this for a long time now any help is welcome, or a totally new approach for this particular problem.
I'm using a SG Note 4 and when I open the Google Maps app and then go to task manager it never shows up, it does when you go to settings, applications, cached..., how can I achieve the same with my app. Im using a map fragment and when moving the camera the cache increases and increases, I imagine people with little knowledge going to task manager and seeing my app using 500mb of ram might end up getting scared and kill it, or worse uninstalling it. Maybe not all manufacturers give users this option but for those that do how can I do this if it's even possible thanks!!
I have designed an android application which is perfectly cool and it's working well. but I feel it's using System badly, Because i have written complicated codes.
I was wondering if i can monitor my application. For example see how much RAM, Network, CPU is using and how fast my app is.
Use Android Monitor in Android Studio.
I am a research student who just started the android programming for 3 weeks and I am trying to write an App which extracts data from accelerometer from the phone and writing it on my phone. My problem is that I would like to run my App (taking data from accelerometer) all time when the phone is up and running. What I mean is that my App has to run all time when somebody is calling, facebooking and so on. Is that possible? I would like to get some references.
What I mean is that my App has to run all time when somebody is
calling, facebooking and so on. Is that possible?
So for long-tasks you can use AsyncTask or Services. If you want to execute some task and it have to run also when its not connected with any Activity(for example Music player, RSS which still run also after release from memory by memory manager), you should decide to use Services and also you can combine Services with AsyncTask.
Services are strong tool but work with them is not trivial. You are able to execute only one Service in time and only one Service can running, one instance, one copy. This all is not free so you have to be careful because when you implement Service too dirty, it may cause premature exhaustion of battery.
There is more approaches how to start Services but you have to read some tutorial and guides.
I recommend to check this: Services, ServicesDemo - Using Android Services, Android Service Tutorial, Local Service | Android Tutorial for Beginners
Also have look at AsyncTask, Android Threads, Handlers and AsyncTask - Tutorial
You can use Services. Look here
If you want your activity of your app to be closed, but still a process should be running at background doing your desired work, then you can use Service, or IntentService (Use intent service, in place like, you want an update after certain period of time).