簡體   English   中英

通過Intent將android.text.format.Time對象從一個活動傳遞到另一個活動

[英]Passing android.text.format.Time object via Intent from one activity to another

有什么方法可以通過Intent傳遞Time類的對象嗎? 我已經搜索了通過Intent傳遞的對象,但是它們不能解決我的問題,因為Time類不繼承Parcelable類或實現Serializable接口。

您可以使用Singleton傳遞對象。 我通常使用這種方法,因為解析對象太復雜了,無法實現如此簡單的目標。

public class Session {

    public static final Session sharedSession = new Session();

    public Time passedTime;

    private Session() {

    }
}

然后,您可以在任何ActivityFragment訪問此passedTime ,如下所示:

Time time = Session.sharedSession.passedTime;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM