parcel

Is it possible to parcel a generic class?

十年热恋 提交于 2019-11-30 22:32:25
问题 I'm trying to create public class MyClass<T extends Parcelable> implements Parcelable . I'm having trouble implementing Parcelable . Is it possible to create a generic class that implements Parcelable ? (Note that T is bounded so that it also must implement Parcelable ). I am running into trouble with the fact that the Parcelable interface requires a static variable: public static final Parcelable.Creator<MyParcelable> CREATOR . Thus I cannot do public static final Parcelable.Creator<MyClass

How To: Parcel a bitmap in Android

百般思念 提交于 2019-11-29 17:21:47
问题 I have a serialized class which I want to add a bitmap to, but Bitmap doesn't support serialize. Instead I thought I'd use a parcel instead, but can't get it to work. Here's some test code using local variables: Parcel parcel; Bitmap sourceBitmap; Bitmap destinationBitmap; parcel = Parcel.obtain(); sourceBitmap = Bitmap.createBitmap(200, 400, Config.ARGB_8888); sourceBitmap.writeToParcel(parcel, 0); destinationBitmap = Bitmap.CREATOR.createFromParcel(parcel); I get the following error on the

How do I use jQuery and jQuery-ui with Parcel (bundler)?

左心房为你撑大大i 提交于 2019-11-29 01:24:17
I installed jquery(3.2.1) and jquery-ui-dist(1.12.1) via npm. (they're not included as script tags in html) In client script I use: window.$ = require('jquery');// plain jQuery stuff works fine import 'jquery-ui-dist'; // breaks whole jQuery, with Error (missing module 8) I encountered similar issues today with an angularjs app & parcel-bundler. It seems that parcel doesn't handle well (for now?) global variables introduced in external modules. Amongst other issues. One way to go about it; you can use plain requires instead of imports like so: var jquery = require("jquery"); window.$ = window

Android 跨进程通信基础

妖精的绣舞 提交于 2019-11-28 15:21:47
Android跨进程通信基础——Binder, BinderProxy, parcel, parcelable, Stub, Stub.Proxy (该文章最早于2013年6月7日发表于有道云笔记 进入阅读 ) 百度、google 过很多文章,都没能找到能够从 API 使用者角度简单描述 Binder,BinderProxy,Parcel,Parcelable,Stub,Stub.Proxy 之间关系的文章,要么高深莫测,要么混乱不清。最终决定还是自己动手,看源码,看文档,现总结如下: Binder,BinderProxy 形成了进程间通信的基础,相当于公路桥梁; Parcel 在 IBinder 基础上传输数据,相当于运输工具; Parcelable 基本数据类型和实现了 Parcelable 接口的复合数据类型才可被 Parcel 传输,相当于摆放整齐、安检合格的货物; Stub,Stub.Proxy 实现跨进程调用的接口,相当于收发货方。 注:Binder,BinderProxy 都实现了 IBinder 接口 下面以 Activity 与 Service 通信为例来分析其运行机制。 示例目的:通过跨进程调用方式在 Activity 进程端调用 Service 进程端的方法。这些方法由接口 RemoteSSO 定义。这里假设两者是运行在不同进程的(也可以运行在相同进程

Android Parcelable and Serializable

只谈情不闲聊 提交于 2019-11-27 21:05:24
So i know it is recommended to use Parcelable instead of Serializable in android, because it is faster. My question is: is that impossible to avoid using Serializable right? If I have a custom object i want to serialize, let's say I have the following class definition public class Person { String name; int Age; ... .... } Making this parcelable is easy, because the Person class contains the types parcel.write*() supports, i.e. there is parcel.writeString and parcel.writeInt Now, what if the Person class is the following: public class PersonTwo { MyCustomObj customObj; String name; int Age; ...

How do I use jQuery and jQuery-ui with Parcel (bundler)?

Deadly 提交于 2019-11-27 15:55:13
问题 I installed jquery(3.2.1) and jquery-ui-dist(1.12.1) via npm. (they're not included as script tags in html) In client script I use: window.$ = require('jquery');// plain jQuery stuff works fine import 'jquery-ui-dist'; // breaks whole jQuery, with Error (missing module 8) 回答1: I encountered similar issues today with an angularjs app & parcel-bundler. It seems that parcel doesn't handle well (for now?) global variables introduced in external modules. Amongst other issues. One way to go about

“BadParcelableException: ClassNotFoundException when unmarshalling <myclass>” while using Parcel.read method that has a ClassLoader as argument

纵然是瞬间 提交于 2019-11-27 11:12:25
Given a custom class org.example.app.MyClass implements Parcelable , I want to write a List<MyClass> to a Parcel. I did the marshalling with List<MyClass> myclassList = ... parcel.writeList(myclassList); whenever I try to unmarshall the class with List<MyClass> myclassList = new ArrayList<MyClass>(); parcel.readList(myclassList, null); there is an "BadParcelableException: ClassNotFoundException when unmarshalling org.example.app.MyClass" exception. What is wrong here? Why is the class not found? Flow Don't unmarshall a custom class (i.e. one provided by your application and not by the Android

Parcelable where/when is describeContents() used?

断了今生、忘了曾经 提交于 2019-11-27 10:32:56
Does anyone know where/when this method of a Parcelable is called? @Override public int describeContents() { return 0; } It has to be overriden. But should I consider doing something useful with it? Ognyan There is a constant defined in Parcelable called CONTENTS_FILE_DESCRIPTOR which is meant to be used in describeContents() to create bitmask return value. Description for CONTENTS_FILE_DESCRIPTOR in the API ref is: Bit masks for use with describeContents(): each bit represents a kind of object considered to have potential special significance when marshalled. Which really means: If you need

Parcel Unmarshalling unknown type code

三世轮回 提交于 2019-11-27 04:25:33
问题 We are getting this error in the Crash reports logged by play store. Cant replicate this in all our testing. Does anyone else have the same problem or solution ? Thing is, we dont even know what to do to replicate this bug. All Parcelable objects have CREATOR, writeToParcel() and contructor defined. All Lists and complex types are initialised and null checked. java.lang.RuntimeException: Unable to start activity ComponentInfo{au.com.company/au.com.company.DetailsActivity}: java.lang

Android Parcelable and Serializable

丶灬走出姿态 提交于 2019-11-26 20:32:18
问题 So i know it is recommended to use Parcelable instead of Serializable in android, because it is faster. My question is: is that impossible to avoid using Serializable right? If I have a custom object i want to serialize, let's say I have the following class definition public class Person { String name; int Age; ... .... } Making this parcelable is easy, because the Person class contains the types parcel.write*() supports, i.e. there is parcel.writeString and parcel.writeInt Now, what if the