Workaround for start service bug (fix #60)
Этот коммит содержится в:
@@ -19,7 +19,6 @@ import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import android.app.ListActivity;
|
||||
@@ -32,7 +31,9 @@ import android.widget.ArrayAdapter;
|
||||
|
||||
public class StatusActivity extends ListActivity {
|
||||
|
||||
private static final List<String> messages = new LinkedList<String>();
|
||||
private static final int LIMIT = 20;
|
||||
|
||||
private static final LinkedList<String> messages = new LinkedList<String>();
|
||||
private static final Set<ArrayAdapter<String>> adapters = new HashSet<ArrayAdapter<String>>();
|
||||
|
||||
private static void notifyAdapters() {
|
||||
@@ -46,6 +47,9 @@ public class StatusActivity extends ListActivity {
|
||||
DateFormat format = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
message = format.format(new Date()) + " - " + message;
|
||||
messages.add(message);
|
||||
while (messages.size() > LIMIT) {
|
||||
messages.removeFirst();
|
||||
}
|
||||
notifyAdapters();
|
||||
}
|
||||
|
||||
|
||||
@@ -58,10 +58,6 @@ public class TraccarService extends Service {
|
||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
|
||||
wakeLock.acquire();
|
||||
}
|
||||
|
||||
public void onStart(Intent intent, int startId) {
|
||||
StatusActivity.addMessage(getString(R.string.status_service_start));
|
||||
|
||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
@@ -85,13 +81,6 @@ public class TraccarService extends Service {
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(preferenceChangeListener);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
onStart(intent, startId);
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
|
||||
Ссылка в новой задаче
Block a user