當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。