Do not hardcode service name in HandlerService

This commit is contained in:
YuviPanda 2013-03-21 23:47:14 +05:30
parent ac5e94bf25
commit 67e3b645cb
2 changed files with 10 additions and 1 deletions

View file

@ -7,6 +7,7 @@ import android.os.*;
public abstract class HandlerService<T> extends Service {
private volatile Looper threadLooper;
private volatile ServiceHandler threadHandler;
private String serviceName;
private final class ServiceHandler extends Handler {
public ServiceHandler(Looper looper) {
@ -39,10 +40,14 @@ public abstract class HandlerService<T> extends Service {
return localBinder;
}
protected HandlerService(String serviceName) {
this.serviceName = serviceName;
}
@Override
public void onCreate() {
super.onCreate();
HandlerThread thread = new HandlerThread("UploadService");
HandlerThread thread = new HandlerThread(serviceName);
thread.start();
threadLooper = thread.getLooper();

View file

@ -39,6 +39,10 @@ public class UploadService extends HandlerService<Contribution> {
public static final int NOTIFICATION_UPLOAD_COMPLETE = 2;
public static final int NOTIFICATION_UPLOAD_FAILED = 3;
protected UploadService(String serviceName) {
super("UploadService");
}
private class NotificationUpdateProgressListener implements ProgressListener {
String notificationTag;