How to create an Android app that alerts the user even if they kill him?

I am invited to create an Android application that receives input from the “central station” and receives a warning, for example, “respond immediately”.

I am new to Android programming, so I have no idea how to get such a live input, so any help would be appreciated.

This question has two parts. I think the first part is up to me. But still, it’s important to find the right path.

1) how will the "central" alert the user? At the moment, I have two solutions:

1.a.) The central part can insert the database record on the server, and the application constantly (1 per minute) sends requests to the php file and asks if there is a record with id = my_id and status = "not read".

1.b.) Central sends SMS to the device, and my application listens for incoming SMS messages from this number.

and the important part:

2) How can I make sure that the device receives a “warning” even if the user has closed the application?

Thanks for any help!

+4
source share
4 answers

I think you're looking for the Google Cloud Messaging API

+1
source

, .

+2

, , push- ,

, , push-

push-, , .

!!

push-

+2

Anudeep , , Service - :

public class YourCustomService extends Service {
...
}

and set the onStartCommand parameter to:

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i("LocalService", "Received start id " + startId + ": " + intent);
    // We want this service to continue running until it is explicitly
    // stopped, so return sticky.
    return START_STICKY;
}

Now you have a service that starts it on its own, when it can allocate a resource regardless of whether the application is running or not, so you can write code that will be launched immediately after the service starts.

Link is useful here

+1
source

All Articles