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


Java Parcel.obtain方法代码示例

本文整理汇总了Java中android.os.Parcel.obtain方法的典型用法代码示例。如果您正苦于以下问题:Java Parcel.obtain方法的具体用法?Java Parcel.obtain怎么用?Java Parcel.obtain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.Parcel的用法示例。


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

示例1: findService

import android.os.Parcel; //导入方法依赖的package包/类
private IBinder findService(String name){
	Parcel data = Parcel.obtain();
	data.writeString(name);
	Parcel reply = Parcel.obtain();
	try {
		mRemoteServiceManager.transact(ServiceContext.GET_SERVICE, data, reply, 0);
		IBinder service = reply.readStrongBinder();
		log("getService result binder = " + service);
		return service;
	} catch (RemoteException e) {
		e.printStackTrace();
		log("getService exception");
		return null;
	} finally {
		data.recycle();
		reply.recycle();
	}
}
 
开发者ID:devyok,项目名称:DroidIPC,代码行数:19,代码来源:ServiceManagerImpl.java

示例2: newSession

import android.os.Parcel; //导入方法依赖的package包/类
public boolean newSession(ICustomTabsCallback callback) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();

    boolean _result;
    try {
        _data.writeInterfaceToken("android.support.customtabs.ICustomTabsService");
        _data.writeStrongBinder(callback != null ? callback.asBinder() : null);
        this.mRemote.transact(3, _data, _reply, 0);
        _reply.readException();
        _result = 0 != _reply.readInt();
    } finally {
        _reply.recycle();
        _data.recycle();
    }

    return _result;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:19,代码来源:ICustomTabsService.java

示例3: playFromUri

import android.os.Parcel; //导入方法依赖的package包/类
public void playFromUri(Uri uri, Bundle extras) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    try {
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        if (uri != null) {
            _data.writeInt(1);
            uri.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }
        if (extras != null) {
            _data.writeInt(1);
            extras.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }
        this.mRemote.transact(16, _data, _reply, 0);
        _reply.readException();
    } finally {
        _reply.recycle();
        _data.recycle();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:25,代码来源:IMediaSession.java

示例4: getPlaybackState

import android.os.Parcel; //导入方法依赖的package包/类
public PlaybackStateCompat getPlaybackState() throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    try {
        PlaybackStateCompat _result;
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        this.mRemote.transact(28, _data, _reply, 0);
        _reply.readException();
        if (_reply.readInt() != 0) {
            _result = (PlaybackStateCompat) PlaybackStateCompat.CREATOR.createFromParcel(_reply);
        } else {
            _result = null;
        }
        _reply.recycle();
        _data.recycle();
        return _result;
    } catch (Throwable th) {
        _reply.recycle();
        _data.recycle();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:22,代码来源:IMediaSession.java

示例5: getDeviceInfo

import android.os.Parcel; //导入方法依赖的package包/类
public DeviceInfo getDeviceInfo(String deviceId) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    try {
        DeviceInfo _result;
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        _data.writeString(deviceId);
        this.mRemote.transact(3, _data, _reply, 0);
        ExceptionUtils.readExceptionFromParcel(_reply);
        if (_reply.readInt() != 0) {
            _result = (DeviceInfo) DeviceInfo.CREATOR.createFromParcel(_reply);
        } else {
            _result = null;
        }
        _reply.recycle();
        _data.recycle();
        return _result;
    } catch (Throwable th) {
        _reply.recycle();
        _data.recycle();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:23,代码来源:RemoteDeviceManager.java

示例6: sendCustomAction

import android.os.Parcel; //导入方法依赖的package包/类
public void sendCustomAction(String action, Bundle args) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    try {
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        _data.writeString(action);
        if (args != null) {
            _data.writeInt(1);
            args.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }
        this.mRemote.transact(26, _data, _reply, 0);
        _reply.readException();
    } finally {
        _reply.recycle();
        _data.recycle();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:20,代码来源:IMediaSession.java

示例7: warmup

import android.os.Parcel; //导入方法依赖的package包/类
public boolean warmup(long flags) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();

    boolean _result;
    try {
        _data.writeInterfaceToken("android.support.customtabs.ICustomTabsService");
        _data.writeLong(flags);
        this.mRemote.transact(2, _data, _reply, 0);
        _reply.readException();
        _result = 0 != _reply.readInt();
    } finally {
        _reply.recycle();
        _data.recycle();
    }

    return _result;
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:19,代码来源:ICustomTabsService.java

示例8: testWriteAndReadParcel

import android.os.Parcel; //导入方法依赖的package包/类
@Test
public void testWriteAndReadParcel() throws Exception {
    Parcel p = Parcel.obtain();
    p.writeParcelable(QUERY_RESPONSE, 0);
    p.setDataPosition(0);
    QueryResponse read = p.readParcelable(QueryResponse.class.getClassLoader());

    assertThat(read.responderPackage).isEqualTo(QUERY_RESPONSE.responderPackage);
    assertThat(read.responseId).isEqualTo(QUERY_RESPONSE.responseId);
    assertThat(read.responseMessage).isEqualTo(QUERY_RESPONSE.responseMessage);
}
 
开发者ID:openid,项目名称:OpenYOLO-Android,代码行数:12,代码来源:QueryResponseTest.java

示例9: parcelable2Bytes

import android.os.Parcel; //导入方法依赖的package包/类
private static byte[] parcelable2Bytes(final Parcelable parcelable) {
    if (parcelable == null) {
        return null;
    }
    Parcel parcel = Parcel.obtain();
    parcelable.writeToParcel(parcel, 0);
    byte[] bytes = parcel.marshall();
    parcel.recycle();
    return bytes;
}
 
开发者ID:imliujun,项目名称:LJFramework,代码行数:11,代码来源:CacheUtils.java

示例10: save

import android.os.Parcel; //导入方法依赖的package包/类
public void save() {
    Parcel p = Parcel.obtain();
    try {
        writeMagic(p);
        p.writeInt(getCurrentVersion());
        writePersistenceData(p);
        FileOutputStream fos = new FileOutputStream(mPersistenceFile);
        fos.write(p.marshall());
        fos.close();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        p.recycle();
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:16,代码来源:PersistenceLayer.java

示例11: parcelable2Bytes

import android.os.Parcel; //导入方法依赖的package包/类
private static byte[] parcelable2Bytes(Parcelable parcelable) {
    if (parcelable == null) return null;
    Parcel parcel = Parcel.obtain();
    parcelable.writeToParcel(parcel, 0);
    byte[] bytes = parcel.marshall();
    parcel.recycle();
    return bytes;
}
 
开发者ID:pan2yong22,项目名称:AndroidUtilCode-master,代码行数:9,代码来源:CacheUtils.java

示例12: sizeAsParcel

import android.os.Parcel; //导入方法依赖的package包/类
/**
 * Measure the size of a typed {@link Bundle} when written to a {@link Parcel}.
 *
 * @param bundle to measure
 * @return size when written to parcel in bytes
 */
public static int sizeAsParcel(@NonNull Bundle bundle) {
    Parcel parcel = Parcel.obtain();
    try {
        parcel.writeBundle(bundle);
        return parcel.dataSize();
    } finally {
        parcel.recycle();
    }
}
 
开发者ID:guardian,项目名称:toolargetool,代码行数:16,代码来源:TooLargeTool.java

示例13: marshall

import android.os.Parcel; //导入方法依赖的package包/类
static byte[] marshall(Object o) {
    Parcel parcel = Parcel.obtain();
    parcel.writeValue(o);
    byte[] result = parcel.marshall();
    parcel.recycle();
    return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:ParcelFn.java

示例14: skipToQueueItem

import android.os.Parcel; //导入方法依赖的package包/类
public void skipToQueueItem(long id) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    try {
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        _data.writeLong(id);
        this.mRemote.transact(17, _data, _reply, 0);
        _reply.readException();
    } finally {
        _reply.recycle();
        _data.recycle();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:14,代码来源:IMediaSession.java

示例15: registerCallbackListener

import android.os.Parcel; //导入方法依赖的package包/类
public void registerCallbackListener(IMediaControllerCallback cb) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    try {
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        _data.writeStrongBinder(cb != null ? cb.asBinder() : null);
        this.mRemote.transact(3, _data, _reply, 0);
        _reply.readException();
    } finally {
        _reply.recycle();
        _data.recycle();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:IMediaSession.java


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