1.in:子行程值不能傳回主行程
代碼:

Log.d(TAG, "onClick: "+String.valueOf(message.isSendSuccess()));
其實他在remoteService設定了isSendSuccess為true,但列印結果是false,即它在remoteService設定為true,但是沒有改變在MainActivity中的值

2.inout:兩個行程可以互動
設定為inout

編譯的時候不通過,會爆紅,添加代碼:

//inout的時候添加
public void readFromParcel(Parcel parcel){
content=parcel.readString();
isSendSuccess=parcel.readByte()==1;
}
然后運行,連接,記得等待5秒,然后列印的值為true,即remoteService改變值,影響了MainActivity

3.out:主行程不能向子行程發資料
out與in反過來
代碼直接修改為out即可

在remoteService中的列印結果為空

轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/213128.html
標籤:其他
上一篇:誰說中國沒有 Linus?中國初代 IT 宗師封神榜
下一篇:三星S20關閉5G訊息狀態圖示
