2009-12-14 21:50:53 -05:00
|
|
|
package com.fsck.k9.service;
|
2009-11-22 12:01:04 -05:00
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.IBinder;
|
|
|
|
import android.util.Log;
|
2009-12-14 21:50:53 -05:00
|
|
|
import com.fsck.k9.K9;
|
2009-11-22 12:01:04 -05:00
|
|
|
|
|
|
|
public class PushService extends CoreService
|
|
|
|
{
|
2009-12-14 21:50:53 -05:00
|
|
|
private static String START_SERVICE = "com.fsck.k9.service.PushService.startService";
|
|
|
|
private static String STOP_SERVICE = "com.fsck.k9.service.PushService.stopService";
|
2009-11-24 19:40:29 -05:00
|
|
|
|
|
|
|
public static void startService(Context context)
|
|
|
|
{
|
2009-11-22 12:01:04 -05:00
|
|
|
Intent i = new Intent();
|
|
|
|
i.setClass(context, PushService.class);
|
|
|
|
i.setAction(PushService.START_SERVICE);
|
2009-12-20 20:48:15 -05:00
|
|
|
addWakeLock(context, i);
|
2009-11-22 12:01:04 -05:00
|
|
|
context.startService(i);
|
|
|
|
}
|
2009-11-24 19:40:29 -05:00
|
|
|
|
|
|
|
public static void stopService(Context context)
|
|
|
|
{
|
2009-11-22 12:01:04 -05:00
|
|
|
Intent i = new Intent();
|
|
|
|
i.setClass(context, PushService.class);
|
|
|
|
i.setAction(PushService.STOP_SERVICE);
|
2009-12-20 20:48:15 -05:00
|
|
|
addWakeLock(context, i);
|
2009-11-22 12:01:04 -05:00
|
|
|
context.startService(i);
|
|
|
|
}
|
2009-11-24 19:40:29 -05:00
|
|
|
|
2009-11-22 12:01:04 -05:00
|
|
|
@Override
|
|
|
|
public void startService(Intent intent, int startId)
|
|
|
|
{
|
|
|
|
if (START_SERVICE.equals(intent.getAction()))
|
|
|
|
{
|
2010-01-02 20:50:25 -05:00
|
|
|
if (K9.DEBUG)
|
|
|
|
Log.i(K9.LOG_TAG, "PushService started with startId = " + startId);
|
2009-11-22 12:01:04 -05:00
|
|
|
}
|
|
|
|
else if (STOP_SERVICE.equals(intent.getAction()))
|
|
|
|
{
|
2010-01-02 20:50:25 -05:00
|
|
|
if (K9.DEBUG)
|
|
|
|
Log.i(K9.LOG_TAG, "PushService stopping with startId = " + startId);
|
2009-11-22 12:01:04 -05:00
|
|
|
stopSelf(startId);
|
|
|
|
}
|
2009-11-24 19:40:29 -05:00
|
|
|
|
2009-11-22 12:01:04 -05:00
|
|
|
}
|
2009-11-24 19:40:29 -05:00
|
|
|
|
2009-11-22 12:01:04 -05:00
|
|
|
@Override
|
|
|
|
public IBinder onBind(Intent arg0)
|
|
|
|
{
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|