0
我想了解在Android開發者網站上的教程:http://developer.android.com/reference/android/app/Service.htmldeveloper.android.com服務教程不清楚
我瞭解大部分預計在那裏它的用途在「遠程Messenger服務示例此位碼「部分教程...
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className,
IBinder service) {
...
Toast.makeText(Binding.this, R.string.remote_service_connected,
Toast.LENGTH_SHORT).show();
}
...其中是Binding.this
定義?這是一個錯字嗎?本教程中還有其他幾個地方使用了Binding.this
,但沒有說明Binding
是什麼或者它是如何初始化的。
Binding.this
被這裏使用這樣的...
void doBindService() {
// Establish a connection with the service. We use an explicit
// class name because there is no reason to be able to let other
// applications replace our component.
bindService(new Intent(Binding.this,
MessengerService.class), mConnection, Context.BIND_AUTO_CREATE);
mIsBound = true;
mCallbackText.setText("Binding.");
}
任何幫助表示讚賞感謝!
是的......我需要將'Binding'更改爲'MainActivity'(我的Activity類的名稱)。謝謝! – 2013-02-25 06:49:24
順便說一句我發現這個http://stackoverflow.com/questions/4300291/example-communication-between-activity-and-service-using-messaging是一個比在developer.android.com上更好的教程。 – 2013-02-25 06:51:21