サービスクラスの実装


・サービスを以下のURLを参考に実装
なんか、運良く一発で動いた!!
http://www.xn--rhq6sw9f0w7aevaf9ak89m.jp/android/androidLecture/Service/Service.html
http://techbooster.jpn.org/andriod/application/3270/


・LocationServiceActivity.this と this は何が違う?
ネストした(インナー)クラスの中から外側のインスタンスのメソッドやフィールドにアクセスするときに利用。
たとえば、以下のような呼び出しに使う。

public class LocationServiceActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    
    View startButton = findViewById(R.id.start_button);
    final OnClickListener onStartButton = new OnClickListener() {
      @Override
      public void onClick(View v) {
        //引数のIntentを渡してサービスをスタートする
        startService(new Intent(LocationServiceActivity.this, LocationService.class));
      }
    };
    
    …