0

这是我的 AIDL PlayerHandleService.aidl:

interface PlayerHandleService {
    void changeTextView();
}

我的活动上的 oncreate():Player_Activity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    this.bindService(new Intent(this,PlayerService.class), mConnection, Context.BIND_AUTO_CREATE);
}

mConnection:

private ServiceConnection mConnection = new ServiceConnection() {

    @Override
    public void onServiceDisconnected(ComponentName name) {
        // TODO Auto-generated method stub
        mpInterface=null;
    }

    @Override
    public void onServiceConnected(ComponentName name, IBinder service) {
        // TODO Auto-generated method stub
        mpInterface = PlayerHandleService.Stub.asInterface(service);
    }
};

现在,在我的活动(Player_Activity)上有一个 TextView,我想使用 AIDL 中的方法 changeTextView() 来更改该 TextView 的内容,我该怎么做?

4

1 回答 1

0

你没有。您的活动会改变自己的TextView.

如果您的服务想要告诉活动做某事,您可以使用某种自定义侦听器,或广播Intent,或Messenger,或createPendingResult(),或可能还有其他技术。

于 2011-09-04T17:27:11.347 回答