當前位置: 首頁>>代碼示例>>Java>>正文


Java Intent.writeToParcel方法代碼示例

本文整理匯總了Java中android.content.Intent.writeToParcel方法的典型用法代碼示例。如果您正苦於以下問題:Java Intent.writeToParcel方法的具體用法?Java Intent.writeToParcel怎麽用?Java Intent.writeToParcel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.writeToParcel方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startActivity

import android.content.Intent; //導入方法依賴的package包/類
public void startActivity(String deviceId, Intent intent) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    try {
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        _data.writeString(deviceId);
        if (intent != null) {
            _data.writeInt(1);
            intent.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }
        this.mRemote.transact(11, _data, _reply, 0);
        ExceptionUtils.readExceptionFromParcel(_reply);
    } finally {
        _reply.recycle();
        _data.recycle();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:20,代碼來源:RemoteDeviceManager.java

示例2: sendBroadcast

import android.content.Intent; //導入方法依賴的package包/類
public void sendBroadcast(String deviceId, Intent intent) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    try {
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        _data.writeString(deviceId);
        if (intent != null) {
            _data.writeInt(1);
            intent.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }
        this.mRemote.transact(12, _data, _reply, 0);
        ExceptionUtils.readExceptionFromParcel(_reply);
    } finally {
        _reply.recycle();
        _data.recycle();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:20,代碼來源:RemoteDeviceManager.java

示例3: onPackageChange

import android.content.Intent; //導入方法依賴的package包/類
public void onPackageChange(String deviceId, Intent intent) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    try {
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        _data.writeString(deviceId);
        if (intent != null) {
            _data.writeInt(1);
            intent.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }
        this.mRemote.transact(5, _data, _reply, 0);
        _reply.readException();
    } finally {
        _reply.recycle();
        _data.recycle();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:20,代碼來源:DeviceCallback.java

示例4: initBroadcastParcel

import android.content.Intent; //導入方法依賴的package包/類
@SuppressLint("Recycle")// when process dead, we should save time to restart and kill self, don`t take a waste of time to recycle
	private void initBroadcastParcel(Context context, String broadcastName){
		Intent intent = new Intent();
        ComponentName componentName = new ComponentName(context.getPackageName(), broadcastName);
        intent.setComponent(componentName);
        intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
		
		/*	 
//      Object contextImpl = ((Application)context.getApplicationContext()).getBaseContext();
        //this context is ContextImpl, get MainThread instance immediately
        Field mainThreadField = context.getClass().getDeclaredField("mMainThread");
        mainThreadField.setAccessible(true);
      	Object mainThread = mainThreadField.get(context);
      	//get ApplicationThread instance
      	Object applicationThread = mainThread.getClass().getMethod("getApplicationThread").invoke(mainThread);  
      	//get Binder
      	Binder callerBinder = (Binder) (applicationThread.getClass().getMethod("asBinder").invoke(applicationThread));
		 */
      
//      	UserHandle userHandle = android.os.Process.myUserHandle();
//      	int handle = (Integer) userHandle.getClass().getMethod("getIdentifier").invoke(userHandle);
		
      	mBroadcastData = Parcel.obtain();
      	mBroadcastData.writeInterfaceToken("android.app.IActivityManager");
//      	mBroadcastData.writeStrongBinder(callerBinder);
      	mBroadcastData.writeStrongBinder(null);
      	intent.writeToParcel(mBroadcastData, 0);
      	mBroadcastData.writeString(intent.resolveTypeIfNeeded(context.getContentResolver()));
      	mBroadcastData.writeStrongBinder(null);
      	mBroadcastData.writeInt(Activity.RESULT_OK);
      	mBroadcastData.writeString(null);
      	mBroadcastData.writeBundle(null);
      	mBroadcastData.writeString(null);
      	mBroadcastData.writeInt(-1);
      	mBroadcastData.writeInt(0);
      	mBroadcastData.writeInt(0);
//      	mBroadcastData.writeInt(handle);
      	mBroadcastData.writeInt(0);
	}
 
開發者ID:paozhuanyinyu,項目名稱:FreshMember,代碼行數:40,代碼來源:DaemonStrategy23.java

示例5: initServiceParcel

import android.content.Intent; //導入方法依賴的package包/類
@SuppressLint("Recycle")// when process dead, we should save time to restart and kill self, don`t take a waste of time to recycle
	private void initServiceParcel(Context context, String serviceName){
		Intent intent = new Intent();
		ComponentName component = new ComponentName(context.getPackageName(), serviceName);
		intent.setComponent(component);
		
		/*  
        //get ContextImpl instance
//          Object contextImpl = ((Application)context.getApplicationContext()).getBaseContext();
          //this context is ContextImpl, get MainThread instance immediately
          Field mainThreadField = context.getClass().getDeclaredField("mMainThread");
          mainThreadField.setAccessible(true);
          Object mainThread = mainThreadField.get(context);
          //get ApplicationThread instance
          Object applicationThread = mainThread.getClass().getMethod("getApplicationThread").invoke(mainThread);  
          //get Binder
          Binder callerBinder = (Binder) (applicationThread.getClass().getMethod("asBinder").invoke(applicationThread));  
          */
          
          //get handle
//          UserHandle userHandle = android.os.Process.myUserHandle();
//          int handle = (Integer) userHandle.getClass().getMethod("getIdentifier").invoke(userHandle);
          
          //write pacel
          mServiceData = Parcel.obtain();
          mServiceData.writeInterfaceToken("android.app.IActivityManager");
          mServiceData.writeStrongBinder(null);
//          mServiceData.writeStrongBinder(callerBinder);
          intent.writeToParcel(mServiceData, 0);
          mServiceData.writeString(null);
//          mServiceData.writeString(intent.resolveTypeIfNeeded(context.getContentResolver()));
          mServiceData.writeInt(0);
//          mServiceData.writeInt(handle);
		
	}
 
開發者ID:paozhuanyinyu,項目名稱:FreshMember,代碼行數:36,代碼來源:DaemonStrategyXiaomi.java

示例6: getParceledIntentSize

import android.content.Intent; //導入方法依賴的package包/類
/**
 * Returns how large the Intent will be in Parcel form, which is helpful for gauging whether
 * Android will deliver the Intent instead of throwing a TransactionTooLargeException.
 *
 * @param intent Intent to get the size of.
 * @return Number of bytes required to parcel the Intent.
 */
public static int getParceledIntentSize(Intent intent) {
    Parcel parcel = Parcel.obtain();
    intent.writeToParcel(parcel, 0);
    return parcel.dataSize();
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:13,代碼來源:IntentUtils.java


注:本文中的android.content.Intent.writeToParcel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。