title: Android service won't start
body: <p>Ok so this is the problem. I do <code>context.startService(serviceIntent)</code>, but i don't get new log message from <code>OnCreate</code> or <code>OnStartCommand</code>.</p>
  
  <p>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="com.distorted.flashnotifier"
      android:versionCode="0"
      android:versionName="0.6" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="16"
          android:targetSdkVersion="19" /&gt;
      &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="com.distorted.flashnotifier.Home"
              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;service android:name="FlashService"
              android:exported="true"
              android:enabled="true"
              android:permission="android.permission.READ_PHONE_STATE"&gt;
          &lt;/service&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>What i already tried:</p>
  
  <ul>
  <li>Changing service name to ".FlashService" and "com.distorted.flashnotifier.FlashService"</li>
  </ul>
  
  <p>Activity code:</p>
  
  <pre><code>private Context cont;
  
  protected void onCreate(Bundle savedInstanceState) {
      cont = getApplicationContext();
  }
  
  public void setNotificator() {
      Intent serviceIntent = new Intent(cont, FlashService.class);
      if(callNotificator){
          cont.startService(serviceIntent);
          Log.d("LOG", "setNotificator works");
      } else {
          cont.stopService(serviceIntent);
      }
  }
  </code></pre>
  
  <p>What have i tried:</p>
  
  <ul>
  <li>changing all "cont" to "this"</li>
  <li>startService(new Intent(cont, FlashService.class));</li>
  </ul>
  
  <p>FlashService.class:</p>
  
  <pre><code>package com.distorted.flashnotifier;
  
  public class FlashService extends Service{
  
      public void OnCreate () {
          Log.d("LOG", "onCreate works");
      }
  
          public int OnStartCommand(Intent intent, int flags, int startId) {
      return START_STICKY;
  }
  
      @Override
      public IBinder onBind(Intent intent) {
          // TODO Auto-generated method stub
          return null;
      }
  }
  </code></pre>
  
  <p>I tried:</p>
  
  <ul>
  <li>moving Log.d to onStartCommand</li>
  <li>changed START_STICKY to super.onStartCommand(intent, flags, startId)</li>
  </ul>
  
  <p>Ok so I get that setNotificator log message, but not the onCreate one.
  Does anyone know how could I make this work? (Thanks for reading the whole thing).
  LogCat doesn't say anything interesting.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>full Activity code:</p>
  
  <pre><code>package com.distorted.flashnotifier;
  
  import java.util.Calendar;
  
  import android.app.Activity;
  import android.app.Dialog;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.Menu;
  import android.view.View;
  import android.widget.Button;
  import android.widget.Switch;
  import android.widget.TimePicker;
  import android.widget.Toast;
  import android.app.TimePickerDialog;
  import android.content.Context;
  import android.content.Intent;
  
  public class Home extends Activity {
  
      private Button timeSelectBut1;
      private Button timeSelectBut2;
      private int hour1;
      private int hour2;
      private int minute1;
      private int minute2;
      static final int TIME_DIALOG_ID1 = 1;
      static final int TIME_DIALOG_ID2 = 2;
      private Switch callSwitch;
      private Switch notificationSwitch;
      private boolean callNotificator;
      private boolean notifNotificator;
      private Context cont;
  
  //IMPORTANT UNTIL timeSelectBut1.setOnClickListener
  
      @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_home);
              cont = getApplicationContext();
          timeSelectBut1 = (Button) findViewById(R.id.selectTimeButton1);
          timeSelectBut1.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  showDialog(TIME_DIALOG_ID1);
              }
          });
          final Calendar cal1 = Calendar.getInstance();
          hour1 = cal1.get(Calendar.HOUR_OF_DAY);
          minute1 = cal1.get(Calendar.MINUTE);
          updateText(1);
  
          timeSelectBut2 = (Button) findViewById(R.id.selectTimeButton2);
          timeSelectBut2.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                      showDialog(TIME_DIALOG_ID2);
                  }
              });
              final Calendar cal2 = Calendar.getInstance();
              hour2 = cal2.get(Calendar.HOUR_OF_DAY);
              minute2 = cal2.get(Calendar.MINUTE);
              updateText(2);
      }
  
      @Override
      protected Dialog onCreateDialog(int id){
          if (id == 1) {
              return new TimePickerDialog(this, mTimeSetListener1, hour1, minute1, true);
          }
          if (id == 2) {
              return new TimePickerDialog(this, mTimeSetListener2, hour2, minute2, true);
          }
          return null;
      }
  
      public void updateText(int id) {
          if (id == 1) timeSelectBut1.setText(pad(hour1) + ":" + pad(minute1));
          if (id == 2) timeSelectBut2.setText(pad(hour2) + ":" + pad(minute2));
      }
  
      private TimePickerDialog.OnTimeSetListener mTimeSetListener1 = new TimePickerDialog.OnTimeSetListener() {
                  public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                      hour1 = hourOfDay;
                      minute1 = minute;
                      updateText(1);
                  }
              };
      private TimePickerDialog.OnTimeSetListener mTimeSetListener2 = new TimePickerDialog.OnTimeSetListener() {
          public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
              hour2 = hourOfDay;
              minute2 = minute;
              updateText(2);
          }
      };
  
      private static String pad(int c) {
          if (c &gt;= 10)
              return String.valueOf(c);
          else
              return "0" + String.valueOf(c);
      }
  
  //IMPORTANT
  
      public void onCallSwitchClicked(View view) {
          boolean on = ((Switch) view).isChecked();
          if (on) {
              callNotificator = true;
              setNotificator();
              //timeSelectBut1.setText("callNotifTrue");
          } else {
              callNotificator = false;
              setNotificator();
              //timeSelectBut1.setText("callNotifFalse");
          }
      }
  
      public void onNotifSwitchClicked(View view) {
          boolean on = ((Switch) view).isChecked();
          if (on) {
              notifNotificator = true;
              //setNotificator();
          } else {
              notifNotificator = false;
              //setNotificator();
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.home, menu);
          return true;
      }
  
  //IMPORTANT
  
      public void setNotificator() {
          Intent serviceIntent = new Intent(this, FlashService.class);
          if(callNotificator){
              startService(serviceIntent);
              Log.d("LOG", "SetNotificator works");
          } else {
              stopService(serviceIntent);
          }
      }
  }
  </code></pre>