Android hidden service - android

Could someone please help me figurate how to make an app that has no icon and starts at the startup?
I want it to start in every startup and keep running all the time, because I want to Toast the name of the sender each time there's an incoming SMS.

I'm not sure what you mean by "hidden" as the O/S generally tries to avoid allowing you to hide behavior from the user. What you want to do is discussed in this question Trying to start a service on boot on Android. That will enable you to launch a service and then by watching for the appropriate intents related to SMS messages you can create the toasts you desire.

Related

Clarification for app to run in background using Service

I am trying to develop an app that should run in the background. I want my app to pop-up a message everyday at a particular time of day. As i read i will have to use 'Service' for this. http://developer.android.com/reference/android/app/Service.html#ProcessLifecycle This link shows an example. But where should my code for pop-up be? I dint understand well from the above link. Another question i have is will the app continue to run even after a reboot?
you can show a notification from the app to show pop up msgs, that is the best practice. though showing dialog is also possible. code will be in service only. see this link
And to keep your application running after reboot you will have to register for BOOT_COMPLETED broadcast and whenever you receive that broadcast, you will have to launch your service again. see this link

How to find whether App is running or not and if App is running then how to find which activity is in front

I have a very hard time to finding real solution.I searched a lot but I cant find any good solution for my problem.
I want to perform some action when user click on notification.So I have to check whether application in background or foreground. If it is in foreground then which activity is running ? There must be simple way to find this.
Please Guide me on this.Any help will be appreciated.
You should listen in two places of your application:
In your activity to show the alert.
In your service to show the notification check if activity is running using one of following solutions.
You have severals answers there summarizing the solutions:
Android: how do I check if activity is running?
Checking if an Android application is running in the background
Because If application is in background then show notification otherwise show alert.
Then you do not care "whether application in background or foreground" or "If it is in foreground then which activity is running".
You simply care that, when the event occurs, either the foreground UI handles it (if there is a foreground UI), or else you show a Notification.
One approach is to use an ordered broadcast, as I blogged about a couple of years ago. Here is a sample app that demonstrates this. Basically, the service(?) sends an ordered broadcast. The UI has a high-priority receiver for that broadcast when it is in the foreground, and it aborts the broadcast and consume the event. You also have a low-priority receiver, one that will only get control if the UI did not consume the event, that will display the Notification.

Android:Running an application continously in background even if user closes the application

I am new to android and I was trying out an app as "Scheduled messaging".
Scenario:
Suppose you want to send some message to your friend at 6PM.
Then you can just make an entry and message will be sent automatically at that time.
But now where I am stuck up is that the application must run always even if user tries to close it because else message wont be sent.
Can anyone please give me a small demo for this.
thanks!!!
You could run your task as a service. Or preferably use an alarm. Have a look at the AlarmManager System Service

How do you ship/enable a separate service in android?

Is it possible to launch a service whenever a phone is booted up?
My question is that, say, I want to have a background service running in the background when the phone is booted up, once it receives a notification, say, a stock price is now above a certain price, then the user will get notified and in the notification center it will launch the actual app if a user chooses to click on it.
My question is, where do I put the tag? In my application manifest? but again, I only want the service to run automatically without user launching my app.
I see here two possibilities for you:
Is the same approach that was proposed by #triad. You can have a broadcast receiver that will start your service.
You can use push notifications. As I understand from the question it is possible in your case. I guess using push notifications will be cheaper (in the context of power) in your case.

Can I prevent the user from stopping my Android application?

The requirement is for an enterprise application. The application will be started on device boot. It will be running in the background and the user should not be able to disable or Stop the application. In Android a user can go to Settings->Application->Manage Application and stop my application. Is there any way to prevent this from happening?
No there is not. You can prevent Android from stopping the application by utilizing a Service and marking it as a foreground service, though this will require your application to display an icon in the status bar.
You can not make your application live forever, but it depends on what you really want to do. It's possible to receive a lot of events of the mobile and execute code even if your Activity/Service is not running. You can use BroadcastReceivers to look for interesting events and then start a service. I do it for an Enterprise Application that sends an event to a main server when the user has received/made a call.

Categories

Resources