Check wheter service has to start after device reboot
<p>I'm trying to implement a service into my application, which is started by an activity. The service if the service has been started, it should run in the background until it is manually stopped (by the activity). The service has to check every incoming SMS for a special string. If the message contains the string the service should respond by sending another SMS (like a Automated Response System (ARS)).
The first problem is that the services is stopped by the system after ca. 60 minutes.
Furthermore the service has to be started after boot if it was running before the system was shut down.
Here's the code from the service:
(I'm sorry for the german comments. I had no time to translate them.)</p>

<pre><code>package [...]
import [...]

public class SMSReaderService extends Service {

public  static String searchString;
private SMSreceiver mSMSreceiver; 
private IntentFilter mIntentFilter; 
private static Messenger outMessenger;
private final Messenger inMessenger = new Messenger(new IncomingHandler());

@Override
public void onCreate() {
    super.onCreate();

    //SMS-received-event receiver 
    mSMSreceiver = new SMSreceiver(); 
    mIntentFilter = new IntentFilter(); 
    mIntentFilter.addAction("android.provider.Telephony.SMS_RECEIVED"); 
    registerReceiver(mSMSreceiver, mIntentFilter);

    // Loggen, dass das Objekt erstellt wurde
    Log.d("SMSReaderService::Created", "SMSReaderService has been Created.");
}

@Override
public IBinder onBind(Intent intent) {
    [...] 
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    searchString = (String) intent.getExtras().get("SERCHVALUE");

    // Loggen, dass der Service gestartet wurde
    Log.d("SMSReaderService::Started", "SMSReaderService has Started.");

    return ???;

}

@Override
public void onDestroy() {
    // Unregister the SMS receiver
    unregisterReceiver(mSMSreceiver);

    // Loggen, dass das Objekt zerstört wurde
    Log.d("SMSReaderService::Object::Destroyed", "SMSReaderService has been destroyed.");

    super.onDestroy();
} 

private class SMSreceiver extends BroadcastReceiver {
    @Override 
    public void onReceive(Context context, Intent intent) 
    { 
        Bundle extras = intent.getExtras(); 
        if ( extras != null ) 
        { 
            [...]
        } 
    } 
}
}
</code></pre>

<p><strong>EDIT:</strong>
Now the service returns <code>START_STICKY</code>. I thougth this would work. (Actually it does, but an error occurs). After 1 hour the logcat shows the following information: </p>

<pre><code>08-03 16:31:29.345: E/AndroidRuntime(9885): java.lang.RuntimeException: Unable to start service de.[...].SMSReaderService@41912c88 with null: java.lang.NullPointerException
08-03 16:31:29.345: E/AndroidRuntime(9885):     at de.[...].SMSReaderService.onStartCommand(SMSReaderService.java:161)

08-03 16:32:20.940: E/AndroidRuntime(9933): java.lang.RuntimeException: Unable to start service de.[...].SMSReaderService@41913a30 with null: java.lang.NullPointerException
08-03 16:32:20.940: E/AndroidRuntime(9933):     at de.[...].SMSReaderService.onStartCommand(SMSReaderService.java:161)
</code></pre>

<p>In the "Anwendungsmanager" (I don't know how it's called in english... Maybe something like "application manager") I can see the the Service running... for 1 second. Then it stops immediatly and tries to restart. After 2 tries it runs. This was while the logcat logs the errors.</p>

<p>Line 161: 
<code>searchString = (String)intent.getExtras().get(GET_SEARCHSTRING_AFTER_START);</code></p>
