showNotification();
// Start up the thread running the service. Note that we create a
// separate thread because the service normally runs in the process's
// main thread, which we don't want to block.
Thread thr = new Thread(null, mTask, "AlarmService_Service");
thr.start();
/**
* The function that runs in our worker thread
*/
Runnable mTask = new Runnable()
{
public void run()
{
// Normally we would do some work here... for our sample, we will
// just sleep for 30 seconds.
long endTime = System.currentTimeMillis() + 15 * 1000;
while (System.currentTimeMillis() < endTime)
{
synchronized (mBinder)
{
try
{
mBinder.wait(endTime - System.currentTimeMillis());
}
catch (Exception e)
{
}
}
}
// Done with our work... stop the service!
AlarmService_Service.this.stopSelf();
}
};
/**
* This is the object that receives interactions from clients. See
* RemoteService for a more complete example.
*/
private final IBinder mBinder = new Binder()
{
@Override
protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException
{
return super.onTransact(code, data, reply, flags);
}
};