Question

Here is my AIDL PlayerHandleService.aidl:

interface PlayerHandleService {
    void changeTextView();
}

The oncreate() on my Activity: Player_Activity:

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

The 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);
    }
};

Now, on my activity (Player_Activity) have an TextView and I want to use method changeTextView() in the AIDL to change the content of that TextView, how I can do that?

Was it helpful?

Solution

You don't. Your activity changes its own TextView.

If your service wants to tell the activity to do something, you can use some sort of custom listener, or a broadcast Intent, or a Messenger, or createPendingResult(), or probably other techniques as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top