[英]Passing android.text.format.Time object via Intent from one activity to another
Is there any way to pass an object of Time
class via Intent
? 有什么方法可以通过
Intent
传递Time
类的对象吗? I have searched for passing objects via Intent
, but they don't solve my problem as the Time
class does not inherit Parcelable
class or implement the Serializable
interface. 我已经搜索了通过
Intent
传递的对象,但是它们不能解决我的问题,因为Time
类不继承Parcelable
类或实现Serializable
接口。
You can pass objects using Singleton
. 您可以使用
Singleton
传递对象。 Pesonally I use this method, since parsing objects is too complex to achieve such a simple goal. 我通常使用这种方法,因为解析对象太复杂了,无法实现如此简单的目标。
public class Session {
public static final Session sharedSession = new Session();
public Time passedTime;
private Session() {
}
}
Then you access to this passedTime
in any Activity
or Fragment
like this: 然后,您可以在任何
Activity
或Fragment
访问此passedTime
,如下所示:
Time time = Session.sharedSession.passedTime;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.