バックグラウンドでも録音できるボイスレコーダーアプリを作りたいです。そこで、サービスを実装しました。私はそれを開始する必要があり、それが開始された後すぐにそれにバインドされます。startServiceとbindServiceは非同期呼び出しだと思います。また、次々と電話をかけると、サービスが正常に開始されていないときにbindServiceが呼び出されることがあります。サービスが開始されたときにbindServiceのみが実行されることを確認するにはどうすればよいですか?
1 に答える
0
I use the following snippet to start and bind to service:
Intent playerIntent = new Intent(activity, PlayerService.class);
activity.startService(playerIntent);
activity.bindService(playerIntent, mConnection, Context.BIND_AUTO_CREATE);
mConnection
is a ServiceConnection instance that receives a onServiceConnected
callback when the service is started and bound. Any time I interact with the service, I ask the ServiceConnection
if the service is bound.
于 2012-08-15T08:05:48.120 に答える