2012年1月29日日曜日

Serviceの開始、停止

Activityからのサービスの開始と停止の指示。

 

// サービスを開始する
Intent i = new Intent(this, android2.study.yohei.MyService.class);
startService(i);

// サービスの停止する
Intent i = new Intent(this, android2.study.yohei.MyService.class);
stopService(i);
インテントを生成して、それを引数に起動するだけなので 意外とシンプルです。

0 件のコメント:

コメントを投稿