Home > Mobile >  Using surface. WriteToParcel (parcel) before you read the contents of the parcel is empty how be to
Using surface. WriteToParcel (parcel) before you read the contents of the parcel is empty how be to

Time:02-24

According to writeToParcel () source, should be the first to write a of type string, why call writeToParcel () after the parcel. The readString () read is empty?
Source:
SurfaceView sv=(SurfaceView) the findViewByID (R.i d.v ideoview);
Parcel request=Parcel. Obtain ();
Sv. GetHolder (). GetSurface () writeToParcel (request, 0);
Request. SetDataPosition (0);
The Log i. (TAG, "read the string" + request. ReadString ());

CodePudding user response:

 
Public class Surface implements Parcelable

Want to read the content of the Parce, must want to write in the Parcel first,
Your Parcel request=Parcel. Obtain (); Only initialization, didn't write any content, request. The readString () must be empty,
You need this request. WriteString (" ");

CodePudding user response:

But not in Surface writeToParcel interface has written a string?
After call writeToParcel why can't we get this string?

CodePudding user response:

That's because the underlying has been read, write in to read and the content of the release

CodePudding user response:

What is this place writeToParcel interface functionality? Call after the parcel is empty,,,
I'm here to the surface object encapsulation in the parcel, then through written jni interface will parcel to the native layer on my side, don't want to add the jni interface pass this surface,
But I now is in the Java layer after call writeToParcel, this parcel is as empty, let alone a native layer

CodePudding user response:

Jni layer surface, and can not directly convert ANativeWindow?

CodePudding user response:

The
reference 4 floor ayaers reply:
what is this place writeToParcel interface functionality? Call after the parcel is empty,,,
I'm here to the surface object encapsulation in the parcel, then through written jni interface will parcel to the native layer on my side, don't want to add the jni interface pass this surface,
But I now is in the Java layer after call writeToParcel, this parcel is as empty, let alone a native layer


The writeToParcel here can carry some custom data

CodePudding user response:

Normal pass through interfaces and jobject surface or through GetFieldID can indeed get Java layer surface of the object, but here I want to use parcel delivery surface need to do?
  • Related