1 package de.cweiske.ouya.louyapi;
3 import android.app.Service;
4 import android.content.Intent;
5 import android.os.IBinder;
6 import android.util.Log;
8 import java.io.IOException;
10 import fi.iki.elonen.NanoHTTPD;
12 public class HttpService extends Service {
15 static String TAG = "HttpService";
18 public void onCreate() {
19 Log.i("service", "start service");
22 server = new HttpServer(8080, getAssets());
24 server.start(NanoHTTPD.SOCKET_READ_TIMEOUT, false);
25 } catch (IOException ioe) {
27 Log.e(TAG, "Couldn't start server:\n" + ioe);
33 public void onDestroy() {
34 Log.i(TAG, "stop service");
39 sendBroadcast(new Intent(this, Autostart.class));
43 public IBinder onBind(Intent intent) {
48 public int onStartCommand(Intent intent, int flags, int startId) {
49 //android shall start the service again if killed
54 public void onTaskRemoved(Intent rootIntent) {
55 Log.i(TAG, "Task removed");
56 super.onTaskRemoved(rootIntent);