title: Android : Some time service is stop in some application
body: <p>Now i am working in Android service. i make folder observer in service . so when any movement in folder than some event will be generate.</p>
  
  <p>here is code:</p>
  
  <pre><code>    @Override
  public void onCreate() {
      // TODO Auto-generated method stub
      super.onCreate();                                               
      Log.v(TAG, "oncreate"); 
      Log.e(TAG, "onStart");
  
  }   
  
  @Override
      public int onStartCommand(Intent intent, int flags, int startId) {
      Log.v(TAG, "onStart");
  
      pathToWatch = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString() +"/Screenshots/";                
  
              observer = new FileObserver(pathToWatch) {
                  @Override                         
                  public void onEvent(int event, final String file) {
  
                      if(event == FileObserver.CREATE)
                      {
                          String Path= pathToWatch+file;
                          Intent intent = new Intent();                                       
                          intent.setAction(MY_ACTION);                                                                    
                          intent.putExtra("DATAPASSED", Path);
                          sendBroadcast(intent);
                      }
                      else
                      {
                          //Log.d(TAG, "File Else [" + pathToWatch + file + "]");
                      }              
                  }           
              };                     
              observer.startWatching();   
  
  
      return Service.START_STICKY;
      }
  </code></pre>
  
  <p>My issue is: </p>
  
  <ol>
  <li><p>when first time launch application that time its not work but second time lunch the application its work properly.</p></li>
  <li><p>After some time my service is automatically stop so my requirement is service is run long time not automatically stop.</p></li>
  </ol>
  
  <p>Any one have idea of my Issue? </p>
  
  <p>thank you in Advance...</p>