title: Android: pass parameter to Service from Activity
body: <p>I'm binding to Service by this way:</p>
  
  <p><strong>Activity class:</strong></p>
  
  <pre><code>ListenLocationService mService;
  @Override
  public void onCreate(Bundle savedInstanceState) {
          ...
          Intent intent = new Intent(this, ListenLocationService.class);
          intent.putExtra("From", "Main");
          bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
          ...
  }
  
  private ServiceConnection mConnection = new ServiceConnection() {
  
          public void onServiceConnected(ComponentName className,
                  IBinder service) {
              LocalBinder binder = (LocalBinder) service;
              mService = binder.getService();         
          }
  
          public void onServiceDisconnected(ComponentName arg0) {
          }
      };
  </code></pre>
  
  <p>This is <code>onBind</code> method of my <strong>Service</strong>:</p>
  
  <pre><code>@Override
  public IBinder onBind(Intent intent) {
      Bundle extras = intent.getExtras(); 
      if(extras == null)
          Log.d("Service","null");
      else
      {
          Log.d("Service","not null");
          String from = (String) extras.get("From");
          if(from.equalsIgnoreCase("Main"))
              StartListenLocation();
      }
      return mBinder;
  }
  </code></pre>
  
  <p>So I have "null" in <code>LogCat</code> - bundle is null in spite of I made <code>intent.putExtra</code> before <code>bindService</code></p>
  
  <p>In general Service works fine. However I need to call <code>StartListenLocation();</code> only from main activity of application (I decide to do this by sending a flag). </p>
  
  <p>How can I send a data to service?Or maybe there's another way to check what activity launched <code>onBind</code>?</p>