I am trying to build an application that can detect if the Messaging application is currently running so I can foreground one of my activity to prompt the user for a password.
What I have done:
1)Created a service that starts running after startup.
Now, what is confusing me:
1)Is the messaging application a process, a thread, a task, or something else?
2)What is its package name that i should write to check if running?
How you can check if an app is running you can read here: https://stackoverflow.com/a/4213851/1183280
Now you have to know the package name. As there are many different messaging applications for android (stock Android, HTC Sense, Handcent SMS, etc.) you will have to check more than just one. I think the one for the stock app is "com.android.mms".
Related
I am developing an application for a business entity. That application should run in the background in every employees' mobile phone. Employees are mostly salesman. The application basically detects location changes and suggest the salesman where they might visit. A kind of reminder application. It also lets other salesmen see where are their teammates.
Right now I am using a foreground activity and it works fine till the system forcefully doesn't kill the service or the phone doesn't reboot due to manual activity or battery discharge.
Ones the application is closed, as of now, the managers in the firm needs to call salespeople to turn on the application once, as on application start it automatically turn on its foreground service. But this is really an extra burden on the management team which can be automated.
I am ok to have any settings based or code based solution. One solution is to root the phones of salespeople and install some extra utility app or write the code based on root APIs, but this will be too much for this simple task.
THe permission RECEIVE_BOOT_COMPLETED was not added properly in the manifest. After adding the permission it worked calmly. In on receive method of the broadcast receiver, I am starting the foreground service.
At the moment, the best way is to use WorkManager https://developer.android.com/topic/libraries/architecture/workmanager/ Yes, it still alpha, but works very good.
From other side, you could work on automating the task "managers in the firm needs to call salespeople to turn on the application once". I mean, an app/backend could automatically call the salesman (with some pre-recorded message) or send SMS to them.
I am trying to build an application in which a service can check whether an external application is running at foreground or not.
For example, when we enter in Google Chrome, this service automatically detects what package has been executed and reacts in one way or another.
It's that even possible?
I have heard about 'getRunningTasks' method but is deprecated on new Android versions
Any suggestion is appreciated.
I have created an app. Works great, but I want some same functionality as gmail uses:
When I receive a new email, I get a notification. I inspected my phone and saw no services or applications running that look like the gmail-app.
I have investigated the AlarmManager and services, but as soon as I stop the app both don't work anymore.
Could someone give me a hint how to accomplish this?
Thanks in advance
I inspected my phone and saw no services or applications running that look like the gmail-app.
Partly, that is because Gmail gets such notifications via broadcast Intents from the OS, via the subsystem we see as C2DM (which is why you do not see a process). Partly, that is because Gmail is part of the firmware and may get some extra benefits as a result, in terms of resisting the normal behaviors that befall an app that is force-stopped.
Could someone give me a hint how to accomplish this?
You can't. Particularly on Android 3.1+, if your app is force-stopped, it will not run again until the user manually runs one of your activities (e.g., from the launcher).
The "service" here is different form one of the application components "service" in Android. I mean that people can not see the app icon in launcher, and, the can not see the app in the program manager in Android.
The most important is that I don't want the user notice the existence of the app.
Is that possible? Is it a "service" in Linux?
Without ROM modifications, you can't make a linux service. I will tell you what you CAN do.
First, your requirements
Not see the app icon in launcher: This can be done by simply not having an activity that supports the ACTION.MAIN and CATEGORY.LAUNCHER intents.
Not see the app in program manager: Unfortunately for you (but fortunately for all users) you can't get around this with a normal application.
Have a service run "all the time": The best you can do here is start a foreground service upon boot of the device. This will cause a notification to be in the users notification bar, but its really the best you can do on stock phones.
I'm trying to find out how applications like Perfect App Protector or Smart Applock Free work.
What mechanism is used?
These applications use a service to monitor whether a new application is trying to launch or not.
It can be done in several ways. If running application matched with the configured application then it is sent back to the background by the service and may ask for lock code, password as you configured earlier. If it matches then you will get the application on the foreground. Otherwise it kills the process from being executed.