这是我的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的内容,我该怎么做?
答案 0 :(得分:0)
你没有。您的活动会更改自己的TextView
。
如果您的服务想告诉活动做某事,您可以使用某种自定义侦听器,广播Intent
,Messenger
或createPendingResult()
,或者可能其他技术也是如此。