package com.example.crystalgame;


import com.example.crystalgame.communication.CommunicationService;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getApplicationContext().startService(new Intent(getBaseContext(), CommunicationService.class));
		setContentView(R.layout.activity_main);
	}
	

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}

@@ -182,16 +182,41 @@
 Intent;%0A
+import android.util.Log;%0A
 import a
@@ -280,16 +280,257 @@
 vity %7B%0A%0A
+%09private Intent communicationIntent;%0A%09%0A%09@Override%0A%09public boolean onCreateOptionsMenu(Menu menu) %7B%0A%09%09// Inflate the menu; this adds items to the action bar if it is present.%0A%09%09getMenuInflater().inflate(R.menu.main, menu);%0A%09%09return true;%0A%09%7D%0A%0A
 %09@Overri
@@ -630,352 +630,632 @@
 ;%0A%09%09
-getApplicationContext().startService(new Intent(getBaseContext(), CommunicationService.class));%0A%09%09setContentView(R.layout.activity_main);%0A%09%7D%0A%09%0A%0A%09@Override%0A%09public boolean onCreateOptionsMenu(Menu menu) %7B%0A%09%09// Inflate the menu; this adds items to the action bar if it is present.%0A%09%09getMenuInflater().inflate(R.menu.main, menu);%0A%09%09return true;%0A%09%7D%0A
+setContentView(R.layout.activity_main);%0A%09%7D%0A%09%0A%09protected void onStart() %7B%0A%09%09super.onStart();%0A%0A%09%09Log.d(%22CommunicationService%22, %22oncreate%22);%0A%09%09communicationIntent = createCommunictionIntent();%0A%09%09getApplicationContext().startService(communicationIntent);%0A%09%7D%0A    %0A    //protected void onRestart();%0A%0A    //protected void onResume();%0A%0A    //protected void onPause();%0A%0A    protected void onStop() %7B%0A    %09getApplicationContext().stopService(communicationIntent);%0A    %7D%0A%0A    //protected void onDestroy();%0A%09%0A    %0A    private Intent createCommunictionIntent() %7B%0A    %09return new Intent(getBaseContext(), CommunicationService.class);%0A    %7D
 %0A%7D%0A

Move the service creation to onStart, add onStop service termination