How do I create a simple app that runs a method or activity without actually opening a gui?
I have the coding for the app already.
For example, a task manager on android I have has an icon that you push and it terminates apps running in the background without having to open an app and then pushing terminate manually.
Do I just remove the layout or do I need to have more than that?
Sorry for using the wrong terms, I'm still learning.
Thanks
Ran into your question by chance, I'm learning on the go myself. But it sound to me you maybe should consider making a service, and not an activity that has a layout. A service can work in the background and interact with other applications, which seems to me is your case.
Android Service API http://developer.android.com/reference/android/app/Service.html
Good luck!
Related
I'm new to Android development and I'd like to develop an app that shows application statistics, but only for their background runs (with background i mean the app is totally closed, also in the multitasking, and it starts to run for doing different jobs, or run always in background for different reasons, for example the messaging apps that must be always running in background...).
For example i would like to know the amount of time of run in background of the app in a certain timespam, how many times the app was started in the background in a certain timespam, the duration time of single run in background of the app etc...
My question is: are there APIs that provide this informations?
If not, is it possible to retrieve this informations in another way?
I'm interested in developing with API 24 (Android 7.0 Nougat) and above.
I have read about ActivityManager and AppUsage, but i can not figure out how they can be useful for my purpose.
Can anyone help me please? Thank you.
I think you can do this with very easy steps first make the application which will run in the background and for this, you can refer to this link.
Link of background running app
after this, you can use SQLite DB to store all log information.
hope this will help you.
I want to create an android app that runs on the background, there should not be any UI or Launcher, app should runs on the startup, Is there any example I could follow, I found few resource but those are not helpful for me
First of all look at the official documentation of Services, see for yourself if this is really what you need. Then for your second part of question, you can ask the system to tell you about the device booting completed and run the service. You can find more here.
I am trying to create a benchmarking app that launches a few apps and measures the load time. Starting a timer and launching an app (via intents) is the easy part. And, if I have source to the child app, I can either have it record the time and pass that back, or I can just have it kill itself completely at some point. But, how do I know when stock apps have finished loading? Or, how can I make them close automatically so that mine is brought to the foreground again to stop the timer? I know the source for stock apps is public, but I don't think it's practical for me to try to modify it. Or is it? I can't tie my benchmarking app to a specific version of Android.
Specifically, I'm interested in measuring load times for the browser, youtube, and mail.
I've looked at using the ActivityManager to get info about running apps, but I think in that case I would have to poll in the background, and I've read that ActivityManager info is not necessarily always up-to-date, anyway.
Any suggestions would be very much appreciated.
I decided to just modify the source and build a version of my app for each version of Android/processor. I won't have to target each device specifically, just processor families (Atom/armV7/etc.)
Getting and compiling Android source is easy
Building a custom version of a stock AOSP app is also not that bad
From there, it's just a matter of using intents to invoke activities and pass information.
Is there any way to programmatically pause an Android app in Phonegap? I would like to mimic the behavior that occurs when you hit the HOME button. I've already had to overwrite the back button handler using this, and while in most cases I want it to do my action, when in a particular state the user would expect the app to minimize, and I want to replicate this behavior.
Keep in mind, on Android this is not the same as closing the app. That is quite easy to do with device.exitApp(); but I would like it to remember its state and keep running in the background. Especially if there's still an asynchronous job being done in the background.
Is there a feature in Phonegap to achieve this?
Possible duplicate of Manually pause an application in Android Phonegap, but I couldn't find some of the tools the OP mentioned there such as navigator, so I was nervious to totally edit and rewrite their post
The simple answer appears to be: no.
However, for anyone else that comes down this path, its not impossible. It's just that there isn't a feature of Phonegap to do it for you.
The Android equivalent of "sleeping an app" is actually just opening another intent. Specifically, opening the "Home" intent would sleep the running app and bring you back to the home screen. But as far as I can tell from asking around and scoping the docs, Phonegap doesn't have a direct way of opening intents.
What you (supposedly) can do is one of two things:
This plugin is supposed to be promising
Call the Java code that does it yourself using the means described here
Mind you, as of right now I've decided to not go any further with this, so I make no promises about either of those means, having not attempted them myself.
I invite anyone else who decides to pursue this further to update their experience here.
I want to launch more than one application at the same time.Like one application should run in the background when a new application is started, and I have to switch between those two application.
If anyone having the code to do this please help me.
Give some website links to know about the multitasking in android and how to achieve it.
If you want to run something in the background, you have to use a Service. Services are not killed except in extreme memory situations. Read the Application Fundamentals for more information.