Android Intent的实质

  • Post author:
  • Post category:其他




Intent的实质是binder

Intent 的实质是binder,如下为代码流程。

常见场景:


Intent intent = newIntent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);


mContext.

sendBroadcast

(intent);



ActivityManagerNative.java



public int

broadcastIntent

(IApplicationThread caller,


Intent intent, String resolvedType, IIntentReceiver resultTo,


intresultCode, String resultData, Bundle map,


String requiredPermission, int appOp, boolean serialized,


boolean sticky, int userId) throws RemoteException


{



mRemote.transact(

BROADCAST_INTENT_TRANSACTION

,data, reply, 0);

//


此处即为


binder


通信机制实现



ActivityManagerNative.java



public booleanonTransact(int code, Parcel data, Parcel reply, int flags)


case

BROADCAST_INTENT_TRANSACTION

:


{



data.enforceInterface(IActivityManager.descriptor);



IBinder b =data.readStrongBinder();


int res =

broadcastIntent

(app,intent, resolvedType, resultTo,

resultCode, resultData,resultExtras, perm, appOp,

serialized, sticky,userId);



版权声明:本文为yacoo_tight原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。