通过Intent将android.text.format.Time对象从一个活动传递到另一个活动

时间:2014-04-04 18:26:30

标签: android

有没有办法通过Time传递Intent课程的对象?我已经通过Intent搜索了传递对象,但它们并没有解决我的问题,因为Time类没有继承Parcelable类或实现Serializable接口。

1 个答案:

答案 0 :(得分:0)

您可以使用Singleton传递对象。 Pesonally我使用这种方法,因为解析对象太复杂,无法实现这么简单的目标。

public class Session {

    public static final Session sharedSession = new Session();

    public Time passedTime;

    private Session() {

    }
}

然后您可以在任意passedTimeActivity中访问此Fragment,如下所示:

Time time = Session.sharedSession.passedTime;