本文整理了Java中android.os.Parcel.recycle()
方法的一些代码示例,展示了Parcel.recycle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parcel.recycle()
方法的具体详情如下:
包路径:android.os.Parcel
类名称:Parcel
方法名:recycle
[英]Put a Parcel object back into the pool. You must not touch the object after this call.
[中]将包裹对象放回池中。通话结束后,请勿触摸物品。
代码示例来源:origin: k9mail/k-9
public static <T> T unmarshall(byte[] bytes, Parcelable.Creator<T> creator) {
Parcel parcel = unmarshall(bytes);
T result = creator.createFromParcel(parcel);
parcel.recycle();
return result;
}
代码示例来源:origin: android-hacker/VirtualXposed
@Override
public void cancel(int jobId) throws android.os.RemoteException {
android.os.Parcel _data = android.os.Parcel.obtain();
android.os.Parcel _reply = android.os.Parcel.obtain();
try {
_data.writeInterfaceToken(DESCRIPTOR);
_data.writeInt(jobId);
mRemote.transact(Stub.TRANSACTION_cancel, _data, _reply, 0);
_reply.readException();
} finally {
_reply.recycle();
_data.recycle();
}
}
代码示例来源:origin: facebook/facebook-android-sdk
private static String encodeUserInfo(UserInfo userInfo) {
Parcel parcel = Parcel.obtain();
parcel.writeValue(userInfo);
byte[] data = parcel.marshall();
parcel.recycle();
return Base64.encodeToString(data, Base64.DEFAULT);
}
}
代码示例来源:origin: android-hacker/VirtualXposed
@Override
public void cancelAll() throws android.os.RemoteException {
android.os.Parcel _data = android.os.Parcel.obtain();
android.os.Parcel _reply = android.os.Parcel.obtain();
try {
_data.writeInterfaceToken(DESCRIPTOR);
mRemote.transact(Stub.TRANSACTION_cancelAll, _data, _reply, 0);
_reply.readException();
} finally {
_reply.recycle();
_data.recycle();
}
}
代码示例来源:origin: facebook/facebook-android-sdk
private static UserInfo decodeUserInfo(String base64EncodedToken) {
byte[] data = Base64.decode(base64EncodedToken, Base64.DEFAULT);
Parcel parcel = Parcel.obtain();
parcel.unmarshall(data, 0, data.length);
parcel.setDataPosition(0);
UserInfo userInfo = (UserInfo) parcel.readValue(UserInfo.class.getClassLoader());
parcel.recycle();
return userInfo;
}
代码示例来源:origin: robolectric/robolectric
@After
public void tearDown() {
parcel.recycle();
}
代码示例来源:origin: commonsguy/cw-omnibus
public static byte[] toByteArray(Parcelable parcelable) {
Parcel parcel=Parcel.obtain();
parcelable.writeToParcel(parcel, 0);
byte[] result=parcel.marshall();
parcel.recycle();
return(result);
}
代码示例来源:origin: k9mail/k-9
public static byte[] marshall(Parcelable parceable) {
Parcel parcel = Parcel.obtain();
parceable.writeToParcel(parcel, 0);
byte[] bytes = parcel.marshall();
parcel.recycle();
return bytes;
}
代码示例来源:origin: robolectric/robolectric
/** Returns a copy of {@code automaticZenRule}. */
private AutomaticZenRule copyAutomaticZenRule(AutomaticZenRule automaticZenRule) {
Parcel parcel = Parcel.obtain();
try {
automaticZenRule.writeToParcel(parcel, /* flags= */ 0);
parcel.setDataPosition(0);
return new AutomaticZenRule(parcel);
} finally {
parcel.recycle();
}
}
代码示例来源:origin: android-hacker/VirtualXposed
public static PendingIntent readPendingIntent(IBinder binder) {
Parcel parcel = Parcel.obtain();
parcel.writeStrongBinder(binder);
parcel.setDataPosition(0);
try {
return PendingIntent.readPendingIntentOrNullFromParcel(parcel);
} finally {
parcel.recycle();
}
}
代码示例来源:origin: commonsguy/cw-omnibus
public static <T> T toParcelable(byte[] bytes,
Parcelable.Creator<T> creator) {
Parcel parcel=Parcel.obtain();
parcel.unmarshall(bytes, 0, bytes.length);
parcel.setDataPosition(0);
T result=creator.createFromParcel(parcel);
parcel.recycle();
return(result);
}
}
代码示例来源:origin: android-hacker/VirtualXposed
private static ScanResult cloneScanResult(Parcelable scanResult) {
Parcel p = Parcel.obtain();
scanResult.writeToParcel(p, 0);
p.setDataPosition(0);
ScanResult newScanResult = Reflect.on(scanResult).field("CREATOR").call("createFromParcel", p).get();
p.recycle();
return newScanResult;
}
代码示例来源:origin: google/ExoPlayer
@Test
public void testParcelable() {
DrmInitData drmInitDataToParcel = new DrmInitData(DATA_1, DATA_2);
Parcel parcel = Parcel.obtain();
drmInitDataToParcel.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
DrmInitData drmInitDataFromParcel = DrmInitData.CREATOR.createFromParcel(parcel);
assertThat(drmInitDataFromParcel).isEqualTo(drmInitDataToParcel);
parcel.recycle();
}
代码示例来源:origin: google/ExoPlayer
@Test
public void testParcelable() {
MdtaMetadataEntry mdtaMetadataEntryToParcel =
new MdtaMetadataEntry("test", new byte[] {1, 2}, 3, 4);
Parcel parcel = Parcel.obtain();
mdtaMetadataEntryToParcel.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
MdtaMetadataEntry mdtaMetadataEntryFromParcel =
MdtaMetadataEntry.CREATOR.createFromParcel(parcel);
assertThat(mdtaMetadataEntryFromParcel).isEqualTo(mdtaMetadataEntryToParcel);
parcel.recycle();
}
}
代码示例来源:origin: google/ExoPlayer
/** Tests {@link SelectionOverride}'s {@link android.os.Parcelable} implementation. */
@Test
public void testSelectionOverrideParcelable() {
int[] tracks = new int[] {2, 3};
SelectionOverride selectionOverrideToParcel =
new SelectionOverride(/* groupIndex= */ 1, tracks);
Parcel parcel = Parcel.obtain();
selectionOverrideToParcel.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
SelectionOverride selectionOverrideFromParcel =
SelectionOverride.CREATOR.createFromParcel(parcel);
assertThat(selectionOverrideFromParcel).isEqualTo(selectionOverrideToParcel);
parcel.recycle();
}
代码示例来源:origin: google/ExoPlayer
@Test
public void testParcelable() {
MlltFrame mlltFrameToParcel =
new MlltFrame(
/* mpegFramesBetweenReference= */ 1,
/* bytesBetweenReference= */ 1,
/* millisecondsBetweenReference= */ 1,
/* bytesDeviations= */ new int[] {1, 2},
/* millisecondsDeviations= */ new int[] {1, 2});
Parcel parcel = Parcel.obtain();
mlltFrameToParcel.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
MlltFrame mlltFrameFromParcel = MlltFrame.CREATOR.createFromParcel(parcel);
assertThat(mlltFrameFromParcel).isEqualTo(mlltFrameToParcel);
parcel.recycle();
}
代码示例来源:origin: google/ExoPlayer
@Test
public void testParcelable() {
Format format1 = Format.createSampleFormat("1", MimeTypes.VIDEO_H264, 0);
Format format2 = Format.createSampleFormat("2", MimeTypes.AUDIO_AAC, 0);
TrackGroup trackGroupToParcel = new TrackGroup(format1, format2);
Parcel parcel = Parcel.obtain();
trackGroupToParcel.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
TrackGroup trackGroupFromParcel = TrackGroup.CREATOR.createFromParcel(parcel);
assertThat(trackGroupFromParcel).isEqualTo(trackGroupToParcel);
parcel.recycle();
}
}
代码示例来源:origin: google/ExoPlayer
@Test
public void testParcelable() {
Id3Frame[] subFrames = new Id3Frame[] {
new TextInformationFrame("TIT2", null, "title"),
new UrlLinkFrame("WXXX", "description", "url")
};
ChapterFrame chapterFrameToParcel = new ChapterFrame("id", 0, 1, 2, 3, subFrames);
Parcel parcel = Parcel.obtain();
chapterFrameToParcel.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
ChapterFrame chapterFrameFromParcel = ChapterFrame.CREATOR.createFromParcel(parcel);
assertThat(chapterFrameFromParcel).isEqualTo(chapterFrameToParcel);
parcel.recycle();
}
代码示例来源:origin: google/ExoPlayer
@Test
public void testParcelable() {
String[] children = new String[] {"child0", "child1"};
Id3Frame[] subFrames = new Id3Frame[] {
new TextInformationFrame("TIT2", null, "title"),
new UrlLinkFrame("WXXX", "description", "url")
};
ChapterTocFrame chapterTocFrameToParcel = new ChapterTocFrame("id", false, true, children,
subFrames);
Parcel parcel = Parcel.obtain();
chapterTocFrameToParcel.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
ChapterTocFrame chapterTocFrameFromParcel = ChapterTocFrame.CREATOR.createFromParcel(parcel);
assertThat(chapterTocFrameFromParcel).isEqualTo(chapterTocFrameToParcel);
parcel.recycle();
}
代码示例来源:origin: google/ExoPlayer
@Test
public void testParcelable() {
Format format1 = Format.createSampleFormat("1", MimeTypes.VIDEO_H264, 0);
Format format2 = Format.createSampleFormat("2", MimeTypes.AUDIO_AAC, 0);
Format format3 = Format.createSampleFormat("3", MimeTypes.VIDEO_H264, 0);
TrackGroup trackGroup1 = new TrackGroup(format1, format2);
TrackGroup trackGroup2 = new TrackGroup(format3);
TrackGroupArray trackGroupArrayToParcel = new TrackGroupArray(trackGroup1, trackGroup2);
Parcel parcel = Parcel.obtain();
trackGroupArrayToParcel.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
TrackGroupArray trackGroupArrayFromParcel = TrackGroupArray.CREATOR.createFromParcel(parcel);
assertThat(trackGroupArrayFromParcel).isEqualTo(trackGroupArrayToParcel);
parcel.recycle();
}
}
内容来源于网络,如有侵权,请联系作者删除!