why system_process kill my service the second time?
<p>I have an android application with a service. The first time I run the service works well but when I run the second time in the same emulator get this message.</p>

<pre><code>04-17 18:27:15.808: D/PackageManager(61):   Services: es.myapp.PhoneService
04-17 18:27:15.817: D/PackageManager(61):   Receivers: es.myapp.ScreenReceiver es.myapp.Receiver
04-17 18:27:15.817: D/PackageManager(61):   Activities: es.myapp.Login es.myapp.TakePhoto
04-17 18:27:16.157: D/dalvikvm(155): GC_EXTERNAL_ALLOC freed 238K, 49% free 3007K/5895K, external 6685K/6692K, paused 67ms
04-17 18:27:16.207: I/installd(34): move /data/dalvik-cache/data@app@es.myapp-1.apk@classes.dex -&gt; /data/dalvik-cache/data@app@es.myapp-1.apk@classes.dex
04-17 18:27:16.207: D/PackageManager(61): New package installed in /data/app/es.myapp-1.apk
04-17 18:27:16.377: D/dalvikvm(155): GC_EXPLICIT freed 99K, 51% free 2921K/5895K, external 4655K/5618K, paused 54ms
04-17 18:27:17.427: I/ActivityManager(61): Force stopping package es.myapp uid=10035
</code></pre>

<p>I have enough memory on the emulator.<br>
So I have to destroy the machine and recreate it each time I run to work well. What is the reason?</p>

<p>The code is as follows:</p>

<pre><code>public class PhoneService extends Service{

    private final IBinder mBinder = new LocalBinder();  

    public class LocalBinder extends Binder {
        PhoneService getService() {
            return PhoneService.this;
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;
    }

    @Override
    public void onCreate(){

        this.setForeground(true);

        try {
            IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
            filter.addAction(Intent.ACTION_SCREEN_OFF);
            filter.addAction(Intent.ACTION_USER_PRESENT);
            BroadcastReceiver mReceiver = new ScreenReceiver();
            registerReceiver(mReceiver, filter);
       } catch (Exception e) {

       }    
    }

       @Override
        public void onDestroy() {
        }


       @Override
       public int onStartCommand(Intent intent, int flags, int startId) {
        super.onStart(intent, startId);
            return START_STICKY;
    }
}





public class Receiver extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {

            Intent serviceIntent = new Intent();
            serviceIntent.setAction("es.myapp.PhoneService");
            context.startService(serviceIntent);
    }
}




public class ScreenReceiver extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {         

        if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)){
            Intent photoIntent = new Intent(context, TakePhoto.class);
            photoIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(photoIntent);
        }
        if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)){

        }
        if (intent.getAction().equals(Intent.ACTION_USER_PRESENT)){

        }
    }
}
</code></pre>

<p>Android Manifest:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="es.myapp"
    android:versionCode="1"
    android:versionName="1.0" &gt;

    &lt;uses-sdk android:minSdkVersion="10" /&gt;
    &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
    &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
    &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
    &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
    &lt;uses-feature android:name="android.hardware.camera" /&gt;
    &lt;uses-feature android:name="android.hardware.camera.autofocus" /&gt; 
    &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
    &lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /&gt;
    &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;


    &lt;application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" &gt;

        &lt;activity
            android:name=".Login"

            android:label="@string/app_name" &gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;
                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt; 

        &lt;activity
            android:name=".TakePhoto"
            android:theme="@android:style/Theme.NoDisplay"
            android:label="@string/app_name" &gt;

        &lt;/activity&gt; 

        &lt;service android:name=".PhoneService"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="es.myapp.PhoneService"/&gt;
            &lt;/intent-filter&gt;
        &lt;/service&gt; 

        &lt;receiver android:name=".ScreenReceiver"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.SCREEN_ON" /&gt; 
                &lt;action android:name="android.intent.action.SCREEN_OFF" /&gt;
                &lt;action android:name="android.Intent.ACTION_USER_PRESENT" /&gt;
            &lt;/intent-filter&gt;
        &lt;/receiver&gt;

        &lt;receiver android:name=".Receiver"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.BOOT_COMPLETED"/&gt;
                &lt;category android:name="android.intent.category.HOME" /&gt;
            &lt;/intent-filter&gt;
        &lt;/receiver&gt;

    &lt;/application&gt;


&lt;/manifest&gt;
</code></pre>

<p>Thanks.</p>
