たぶん、ですが、
(10/11/13 8:58), S. Kimura wrote:
> ・ActivityではonCreateメソッドで下記のようにServiceを初期化
> // 通知用のサービスを生成
> Intent intent = new Intent(this, TimerAlarmService.class);
略...........
> // サービスにバインド
> bindService(intent, this.connection_,
> Context.BIND_AUTO_CREATE);
この、bindServiceするintentが、間違っているのではないでしょうか?
自分が以前書いたコードは以下のようになっていました。
private boolean bindHogeHoge() {
if( m_HogeHogeServiceIf == null ) {
Intent intent_bind = new Intent(IHogeHoge.class.getName());
if( true != bindService(intent_bind, m_HogeHogeServiceConn, 0) ) {
// Error
stopService(new Intent(this, HogeHoge.class));
return(false);
}
}
return(true);
}
S. Kimuraさんのコードでは、bindServiceの第一引数に、Serviceの
intentをセットしているように見えますが、私はaidlから自動生成
されたinterfaceである、IHogeHogeを使っています。
bindServiceの本質として、interfaceをintentに使うのはまっとうで
あろうと勝手に解釈しています。(今reference読んだけど、意味が
わからんかった。。。笑)
それと、bindServiceの戻り値を是非チェックしてエラー処理を
書くようにしましょう。Serviceの場合結構重要だと思います。