X-Git-Url: https://git.cweiske.de/louyapi.git/blobdiff_plain/de7477d8bf4428ce9777b19f2b7b8a144f9ab1a2..d6a38bbd92c86a3d2266e90f6eb7d0b0152a5126:/src/main/java/de/cweiske/ouya/louyapi/MainActivity.java diff --git a/src/main/java/de/cweiske/ouya/louyapi/MainActivity.java b/src/main/java/de/cweiske/ouya/louyapi/MainActivity.java new file mode 100644 index 0000000..c5ca1c2 --- /dev/null +++ b/src/main/java/de/cweiske/ouya/louyapi/MainActivity.java @@ -0,0 +1,30 @@ +package de.cweiske.ouya.louyapi; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; + +public class MainActivity extends Activity { + + protected Intent serviceIntent; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + serviceIntent = new Intent(this, HttpService.class); + startService(serviceIntent); + } + + /** + * Why do we want to stop exactly the service that we want to keep alive? + * Because if we do not stop it, the service will die with our app. + * Instead, by stopping the service, we will force the service to call its + * own onDestroy which will force it to recreate itself after the app is dead. + */ + protected void onDestroy() { + stopService(serviceIntent); + super.onDestroy(); + } +} \ No newline at end of file