当前位置: 首页>>代码示例>>Java>>正文


Java ParcelFormatException类代码示例

本文整理汇总了Java中android.os.ParcelFormatException的典型用法代码示例。如果您正苦于以下问题:Java ParcelFormatException类的具体用法?Java ParcelFormatException怎么用?Java ParcelFormatException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ParcelFormatException类属于android.os包,在下文中一共展示了ParcelFormatException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeToParcel

import android.os.ParcelFormatException; //导入依赖的package包/类
@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeFloat(this.x);
    dest.writeFloat(this.getY());
    if (getData() != null) {
        if (getData() instanceof Parcelable) {
            dest.writeInt(1);
            dest.writeParcelable((Parcelable) this.getData(), flags);
        } else {
            throw new ParcelFormatException("Cannot parcel an Entry with non-parcelable data");
        }
    } else {
        dest.writeInt(0);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:Entry.java

示例2: writeToParcel

import android.os.ParcelFormatException; //导入依赖的package包/类
@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeFloat(this.mVal);
    dest.writeInt(this.mXIndex);
    if (mData != null) {
        if (mData instanceof Parcelable) {
            dest.writeInt(1);
            dest.writeParcelable((Parcelable) this.mData, flags);
        } else {
            throw new ParcelFormatException("Cannot parcel an Entry with non-parcelable data");
        }
    } else {
        dest.writeInt(0);
    }
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:16,代码来源:Entry.java

示例3: writeToParcel

import android.os.ParcelFormatException; //导入依赖的package包/类
@Override
public void writeToParcel(Parcel parcel, int i) {
    try {
        parcel.writeString(this.uid);
        parcel.writeString(this.name);
        parcel.writeString(this.image);
        parcel.writeString(this.email);
        parcel.writeLong(this.lastSeen);
        parcel.writeString(this.fcm);
    } catch (ParcelFormatException e) {
        e.printStackTrace();
    }
}
 
开发者ID:marcovann,项目名称:Firebase-Chat-Demo,代码行数:14,代码来源:User.java

示例4: writeToParcel

import android.os.ParcelFormatException; //导入依赖的package包/类
@Override
public void writeToParcel(Parcel parcel, int i) {
    try {
        parcel.writeString(this.uid);
        parcel.writeString(this.name);
        parcel.writeString(this.image);
        parcel.writeString(this.message);
        parcel.writeString(this.time);
    } catch (ParcelFormatException e) {
        e.printStackTrace();
    }
}
 
开发者ID:marcovann,项目名称:Firebase-Chat-Demo,代码行数:13,代码来源:Conversation.java

示例5: parseWearActions

import android.os.ParcelFormatException; //导入依赖的package包/类
public static void parseWearActions(Context context, Notification notification, PebbleNotification pebbleNotification, List<NotificationAction> storage)
{
    try
    {
        if (storage.size() >= NotificationAction.MAX_NUMBER_OF_ACTIONS)
            return;

        Bundle extras = NotificationTextParser.getExtras(notification);

        if (extras.containsKey("android.wearable.EXTENSIONS"))
        {
            Bundle wearExtras = extras.getBundle("android.wearable.EXTENSIONS");

            if (wearExtras.containsKey("actions"))
            {
                ArrayList<?> actionList = (ArrayList<?>) wearExtras.get("actions");
                for (Object obj : actionList)
                {
                    if (storage.size() >= NotificationAction.MAX_NUMBER_OF_ACTIONS)
                        break;

                    NotificationAction action = null;

                    if (obj instanceof  Bundle)
                        action = WearVoiceAction.parseFromBundle((Bundle) obj);
                    else if (obj instanceof Notification.Action)
                        action = WearVoiceAction.parseFromAction((Notification.Action) obj);

                    if (action != null)
                        storage.add(action);
                }
            }

            if (storage.size() >= NotificationAction.MAX_NUMBER_OF_ACTIONS)
                return;

            if (wearExtras.containsKey("pages"))
            {
                Parcelable[] pages = wearExtras.getParcelableArray("pages");
                int counter = 1;
                for (Parcelable page : pages)
                {
                    if (storage.size() >= NotificationAction.MAX_NUMBER_OF_ACTIONS)
                        return;

                    PebbleNotification pageNotification = NotificationHandler.getPebbleNotificationFromAndroidNotification(context, new NotificationKey(pebbleNotification.getKey().getPackage(), null, null), (Notification) page, false);
                    if (pageNotification == null)
                        continue;

                    pageNotification.setForceSwitch(true);
                    pageNotification.setText(TextUtil.trimStringFromBack(pageNotification.getText(), NotificationSendingModule.getMaximumTextLength(pebbleNotification.getSettingStorage(context))));

                    storage.add(new NotifyAction(context.getString(R.string.wearPageAction, counter), pageNotification));

                    counter++;
                }
            }
        }
    }
    catch (ParcelFormatException e) //Some phones (or apps?) seems to throw this when unparceling data.
    {
        Timber.w("Got ParcelFormatException at parseWearActions!");
    }
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:65,代码来源:ActionParser.java


注:本文中的android.os.ParcelFormatException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。