質問

これが私の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の内容を変更したいのですが、どうすればできますか?

役に立ちましたか?

解決

あなたはそうしない。あなたの活動はそれ自体を変えます TextView.

サービスがアクティビティに何かをするように伝えたい場合は、ある種のカスタムリスナー、または放送を使用できます Intent, 、またはa Messenger, 、 また createPendingResult(), 、またはおそらく他のテクニックも同様です。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top