ローカル サービスがあり、プログラムを onServiceConnected メソッドでさらに進めます。
intentaudio=new Intent(this,AudioService.class);
sConn=new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
// TODO Auto-generated method stub
bound=false;
}
@Override
public void onServiceConnected(ComponentName name, IBinder binder) {
// TODO Auto-generated method stub
audioService = ((AudioService.MyBinder) binder).getService();
bound = true;
body(); //this is the main code for the Activity - I moved it to separate method
}
};
startService(intentaudio);
bindService(intentaudio, sConn, 0);
したがって、このアクティビティ中に別のアクティビティを開始します。
intent=new Intent(mContext,Prayer.class);
startActivityForResult(intent,1);
2 番目のアクティビティはうまくいきますが、戻るとどうすればよいかわかりません。
onActivityResult - 接続するためのサービスが必要なので、別のことを行う必要があります
sConn=new ServiceConnection() {
...などですが、アクティビティをサービスに接続するにはどうすればよいですか? ご覧のとおり、アクティビティ全体が onServiceConnected
メソッド内にあるため、すぐにサービスと対話できます。だから..どうしたらいいのかわからない。
助けてください!