简体   繁体   English

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

[英]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: 然后,您可以在任何ActivityFragment访问此passedTime ,如下所示:

Time time = Session.sharedSession.passedTime;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android-将对象的意图从一个活动传递到另一个活动(崩溃) - Android - Passing intent with object from one activity to another (crashing) android.text.format.Time替换需要,因为它已被弃用 - android.text.format.Time replacement need as it is deprecated Android.text.format.Time没有正确设置isDst? - Android.text.format.Time not setting isDst correctly? 将对象从一个android活动传递到另一个 - Passing an object from one android activity to another 将数组意图从一个活动传递到另一个活动 - Passing arraylist in intent from one activity to another Android-将一个活动中的整数值传递给Android本机隐式意图并接收到另一个活动 - Android - Passing integer value from One Activity to Android Native implicit intent and recive to another activity 我想通过Intent将Drawable中的图像从一个活动传递到另一个活动? - I want to Passing a image from Drawable from one activity to Another via Intent? 将数据从一个活动中的两个不同意图传递到另一个活动 - Passing data from two different intent in one activity to another activity Android 将 JsonArray 从一个意图传递到另一个意图 - Android passing JsonArray from one intent to another 如何使用Xamarin在Android中通过意图将列表从一个活动传递到另一个活动 - How to pass List via intent from one activity to another activity in android using xamarin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM