Android开发之广播的基本使用说明_第1页
Android开发之广播的基本使用说明_第2页
Android开发之广播的基本使用说明_第3页
Android开发之广播的基本使用说明_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、¡¡¡¡1¡¢Android¹ã²¥·¢Ëͼ°¹ã²¥ÀàÐÍ¡¡¡¡¹ã²¥·¢Ë͵Ļù±¾´úÂë:¡¡

2、61;¡¸ù¾Ý¹ã²¥µÄ·¢ËÍ·½Ê½£¬¿ÉÒÔ½«Æä·ÖΪÒÔϼ¸ÖÖÀàÐÍ£º¡¡

3、61;¡1£©ÆÕͨ¹ã²¥ Normal Broadcast¡¡¡¡2£©ÏµÍ³¹ã²¥ System Broadcast¡¡¡¡3) ÓÐÐò¹ã²¥ Ordered Broadcast¡¡¡

4、¡4£©Õ³ÐԹ㲥 Sticky Broadcast (ÔÚAndroid 5.0/Api 21Öв»ÍƼöʹÓã¬ÓÐÐòÕ³ÐԹ㲥ҲÒÑ

5、0;­²»ÍƼöʹÓÃ)¡¡¡¡5£©Ó¦ÓÃÄڹ㲥 Local Broadcast£¨Ê¹ÓÃLocalBroadcastManager£¬Ö»ÄÜÔÚÓ¦&

6、#211;ÃÄÚʹÓ㬲»ÄÜ¿ç½ø³ÌʹÓᣣ©¡¡¡¡1£©ÆÕͨ¹ã²¥ Normal Broadcast¡¡¡¡¿&

7、#170;·¢Õß×Ô¼º¶¨ÒåµÄintent,ÒÔcontext.sendBroadcast(.)»òÕßcontext.sendBroadcastAsUser(.)ÐÎʽ·¢ËÍ¡£¡¡¡¡¾ßÌå¿

8、ÉÒÔʹÓõķ½·¨ÓУº¡¡¡¡sendBroadcast(.):¡¡¡¡¢ÙsendBroadcast(RequiresPermission Intent intent);¡¡¡¡¢ÚsendBroadcast(RequiresPermission Inte

9、nt intent, Nullable String receiverPermission);¡¡¡¡¢ÛsendBroadcast(Intent intent, Nullable String receiverPermission, Nullable Bundle options);¡¡¡¡¢ÜsendBroadcast(Intent intent, String receiverPermission, int appOp);¡¡¡¡

10、sendBoadcastAsUser(.)¡¡¡¡¢ÙsendBroadcastAsUser(RequiresPermission Intent intent, UserHandle user);¡¡¡¡¢ÚsendBroadcastAsUser(RequiresPermission Intent intent, UserHandle user, Nullable String receiverPermission);¡¡¡¡¢

11、;ÛsendBroadcastAsUser(RequiresPermission Intent intent, UserHandle user, Nullable String receiverPermission, int appOp);¡¡¡¡2£©ÏµÍ³¹ã²¥ System Broadcast¡¡¡¡AndroidϵͳÄÚÖ

12、ÃÁ˶à¸ö¹ã²¥£¬Éæ¼°µ½ÊÖ»úµÄ»ù±¾²Ù×÷£¬»ù±¾É϶¼»á·¢³öÏ

13、àÓ¦µÄϵͳ¹ã²¥¡£¡¡¡¡ÏµÍ³¹ã²¥ÔÚϵͳÄÚ²¿µ±Ìض¨Ê¼þ·¢É

14、úʱ£¬ÓÉϵͳ·¢³ö¡£¡¡¡¡3£©ÓÐÐò¹ã²¥ Ordered Broadcast¡¡¡¡ÓÐÐò¹ã²¥ÊÇÕë

15、;¶Ô¹ã²¥½ÓÊÕÕߣ¨BroadcastReceiver£©¶øÑÔ£¬°´ÕÕÏȺó˳Ðò½ÓÊյġ£¡¡¡¡Ï

16、Ⱥó˳ÐòÅжϱê׼Ϊ£º°´ÕÕPriorityÓÉ´óµ½Ð¡ÅÅÐò£»ÓÐÏàͬpriorityµÄ¶¯&#

17、204;¬¹ã²¥ºÍ¾²Ì¬¹ã²¥£¬¶¯Ì¬¹ã²¥»áÅÅÔÚÇ°Ãæ¡£¡¡¡¡4£©Õ³ÐÔ¹ã&

18、#178;¥(Sticky Broadcast)¡¡¡¡ÒѾ­ÔÚAndroid 5.0/Api 21Öв»ÍƼöʹÓá¡¡¡5£©Ó¦ÓÃÄڹ㲥(Local Broadcast)¡&

19、#161;¡¡ÓÃLocalBroadcastManagerͳһ´¦ÀíAPPÓ¦ÓÃÄڵĹ㲥ÎÊÌâ¡£¡¡¡¡Android¹ã²¥¿ÉÒÔ¿ç

20、½ø³ÌÉõÖÁ¿çAPP·¢ËÍ£¬»áÔì³ÉÒ»ÏÂÎÊÌ⣺¡¡¡¡¢ÙÆäËûÓ¦ÓÿÉÄ

21、20;»áÕë¶Ôµ±Ç°APP£¬·¢ËÍÓ뵱ǰAPP intent-filterÒ»ÖµĹ㲥£¬µ¼ÖÂAPP²»¶ÏµÄ½

22、1;Êպʹ¦Àí£»¡¡¡¡¢ÚÆäËûÓ¦ÓÿÉÒÔ×¢²áÓ뵱ǰAPP intent-filterÒ»ÖµĹã²

23、;¥£¬ÓÃÓÚ½ÓÊչ㲥ÐÅÏ¢¡£¡¡¡¡ÒÔÉÏÁ½ÖÖÇé¿ö¶¼´æÔÚ°²È«Òþ»

24、;¼£¬³£¼ûµÄÔö¼Ó°²È«ÐԵķ½°¸ÊÇ£º¡¡¡¡¢Ù±¾µØAPPÄÚ²¿·¢ËͺÍ&#

25、189;ÓÊյĹ㲥£¬½«exportedÊôÐÔÉèΪfalse¡£¡¡¡¡¢ÚÔÚ·¢ËͺͽÓÊչ㲥ʱ&

26、#163;¬Ôö¼ÓÉÏÏàÓ¦µÄpermission£¬ÓÃÓÚȨÏÞÑéÖ¤¡£¡¡¡¡¢Û·¢Ë͹㲥ʱ£¬

27、14;¸¶¨¹ã²¥½ÓÊÕÆ÷ËùÔڵİüÃû¡¡¡¡2¡¢¹ã²¥·¢ËͺͽÓÊÕµÄÔ­Àí&#

28、161;¡¡¡³ýÓ¦ÓÃÄڹ㲥£¬ÆäËû¹ã²¥·¢ËͺͽÓÊÕÔ­Àí¡¡¡¡¢Ù¼Ì³ÐBr

29、oadcastReceiver£¬ÖØдonReceive()·½·¨£»¡¡¡¡¢Úͨ¹ýBinder»úÖÆÏòActivityManagerService×¢²á¹ã²¥¡¡¡¡¢

30、Ûͨ¹ýBinder»úÖÆÏòActivityManagerService·¢Ë͹㲥¡¡¡¡¢ÜAMS²éÕÒ·ûºÏÌõ¼þ£¨IntentFilter/Permission£©

31、µÄBroadcastReceiver£¬½«¹ã²¥·¢Ë͵½BroadcastReceiverËùÔÚµÄÏûÏ¢¶ÓÁÐÖС£¡¡¡¡¢ÝBroadcastReceiverË

32、49;ÔڵĶÓÁÐÊÕµ½´Ë¹ã²¥ºó£¬»Øµ÷onReceive()·½·¨¡£¡¡¡¡Ó¦ÓÃÄڹ㲥£

33、2;·¢ËͺͽÓÊÕÔ­ÀíÓëÆÕͨ¹ã²¥»ù±¾Ò»Ö£¬½«ActivityManagerService»»ÎªLocalManagerService¿ØÖ

34、;ƹ㲥µÄ½ÓÊպͷ¢Ë͵ÈÁ÷³Ì¡£¡¡¡¡3¡¢¹ã²¥Êý¾ÝµÄÏÞÖÆ£¨Î´

35、9;éÖ¤£¬´ýÑéÖ¤£©¡¡¡¡¹ã²¥´«ÊäÊý¾Ý´óСӦ¸Ã¾¡¿ÉÄܵÄС¡£

36、8;»ÄÜÌ«´ó¡£Í¼Æ¬»òÕßÌ«³¤µÄ×Ö·û´®Ó¦¸ÃÒÔ±ðµÄ·½Ê½´«µÝ¡£

37、1;¡¡¡½ø³ÌÄÚ£¬¿ÉÒÔÓÃEventBus£¬Îļþ»º´æ£¬´ÅÅÌ»º´æ¡£¡¡¡¡¹ÙÍøÉ&#

38、207;¶ÔTransationTooLargeExceptionÓÐÈçÏÂ˵Ã÷£º¡¡¡¡TransactionTooLargeException¡¡¡¡The Binder transaction failed because it was too large.¡¡¡¡During a remote procedure call

39、, the arguments and the return value of the call are transferred asParcelobjects stored in the Binder transaction buffer. If the arguments or the return value are too large to fit in the transaction buffer, then the call will fail andTransactionTooLargeExceptionwill be thrown.¡¡¡¡

40、;The Binder transaction buffer has a limited fixed size, currently 1Mb, which is shared by all transactions in progress for the process. Consequently this exception can be thrown when there are many transactions in progress even when most of the individual transactions are of moderate size.¡

41、61;¡¡There are two possible outcomes when a remote procedure call throwsTransactionTooLargeException. Either the client was unable to send its request to the service (most likely if the arguments were too large to fit in the transaction buffer), or the service was unable to send its respon

42、se back to the client (most likely if the return value was too large to fit in the transaction buffer). It is not possible to tell which of these outcomes actually occurred. The client should assume that a partial failure occurred.¡¡¡¡The key to avoidingTransactionTooLargeExcepti

43、onis to keep all transactions relatively small. Try to minimize the amount of memory needed to create aParcelfor the arguments and the return value of the remote procedure call. Avoid transferring huge arrays of strings or large bitmaps. If possible, try to break up big requests into smaller pieces.

44、¡¡¡¡Òâ˼´ó¸ÅÊÇ˵¡¡¡¡Í¨¹ýBinder»º³åÇøÖеÄParcel¶ÔÏó½øÐд«Êä¡£

45、BinderÊÂÎñ»º³åÇø¾ßÓÐÓÐÏ޵Ĺ̶¨´óС£¬µ±Ç°Îª1Mb¡£¡¡¡¡Óɵ±Ç°

46、89;ø³ÌÕýÔÚ½øÐеÄËùÓÐÊÂÎñ¹²Ïí¡£Òò´Ë£¬¼´Ê¹´ó¶àÊýµ¥¸öÊÂ

47、06;ñµÄ´óСÊÊÖУ¬µ±ÓÐÐí¶àÊÂÎñÕýÔÚ½øÐÐʱ£¬Ò²»áÅ׳ö´ËÒì

48、79;£¡£¡¡¡¡µ±Å׳öTransactionTooLargeExceptionʱ£¬ÓÐÁ½ÖÖ¿ÉÄܵÃÔ­Òò¡£¿Í»§¶ËÎÞ·¨

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论