Android上的otto的使用

2021-06-25 20:27:00 字數 347 閱讀 2843

類此與廣播,但是比廣播更輕的乙個框架,通過在傳送的地方註冊,傳送要傳送的資料到post裡面,然後在接受的地方反註冊,寫個方法接受該事件就好了。。。。但是要注意的是反註冊在不同的activity中的時候,要把onpause中的反註冊寫到ondestroy中才能收到傳送的訊息。

//註冊otto

@override public void onresume()

//解綁otto

@override public void onpause()

@override public void ondestroy()

github上的開源****,裡面有個****** demo,參照著做就可以了。

Otto匯流排的基本使用

otto,與eventbus的使用相似,能 程間傳遞資料 一般可以用來代替handler進行資料的傳遞,可以進行一對多的資料傳送,這可以滿足有些應用場景。其中bus物件可以定義為全域性的。一般使用步驟 註冊接受者,接受者一般可以在activity或fragment 接受者接受資料,用 subscri...

Android之Animations的使用

animations一般分為兩大類,一類是漸變的 tweened 如淡入淡出,旋轉,移動,縮放 另一類是frame by frame,就如電影一般由多張按照一定的時間間隔顯示。使用tweened animations的第一種使用步驟 1.建立乙個animationset物件,animationset...

android的m mm mmm編譯命令的使用

android原始碼目錄下的build envsetup.sh檔案,描述編譯的命令 m makes from the top of the tree.mm builds all of the modules in the current directory.mmm builds all of the...