Android进程间通信

  • P2_332530
    了解作者
  • 525.8KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-13 05:35
    上传日期
Android进程间通信
第六章_Android进程间通信.rar
  • 第六章_Android进程间通信.pdf
    557.4KB
内容介绍
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="utf-8"><meta name="generator" content="pdf2htmlEX"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><link rel="stylesheet" href="https://csdnimg.cn/release/download_crawler_static/css/base.min.css"><link rel="stylesheet" href="https://csdnimg.cn/release/download_crawler_static/css/fancy.min.css"><link rel="stylesheet" href="https://csdnimg.cn/release/download_crawler_static/4791098/raw.css"><script src="https://csdnimg.cn/release/download_crawler_static/js/compatibility.min.js"></script><script src="https://csdnimg.cn/release/download_crawler_static/js/pdf2htmlEX.min.js"></script><script>try{pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({});}catch(e){}</script><title></title></head><body><div id="sidebar" style="display: none"><div id="outline"></div></div><div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://csdnimg.cn/release/download_crawler_static/4791098/bg1.jpg"><div class="t m0 x1 h2 y1 ff1 fs0 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h2 y2 ff1 fs0 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h3 y3 ff2 fs1 fc0 sc1 ls1 ws0">&#31532;&#20845;&#31456;<span class="ff3 sc0 ls0"> <span class="_ _0"> </span>Android<span class="_ _1"> </span></span><span class="ls0">&#36827;&#31243;&#38388;<span class="_ _2"></span>&#36890;&#20449;<span class="_ _2"></span><span class="ff3 sc0"> </span></span></div><div class="t m0 x2 h4 y4 ff2 fs2 fc0 sc0 ls0 ws0">&#36825;&#31687;&#25991;&#31456;&#35762;&#20171;<span class="_ _3"></span>&#32461;<span class="_ _4"> </span><span class="ff1">Andro<span class="_ _3"></span>id<span class="_"> </span><span class="ff2">&#26694;&#26550;&#23618;&#25552;&#20379;&#30340;&#19968;&#20123;&#36890;<span class="_ _3"></span>&#20449;&#26426;&#21046;<span class="_ _4"> </span><span class="ff1">Bro<span class="_ _3"></span>adcas<span class="_ _3"></span>t<span class="ff2">&#12289;</span>Int<span class="_ _3"></span>ent<span class="ff2">&#12289;</span>Con<span class="_ _3"></span>ten<span class="_ _3"></span>t <span class="_ _5"> </span>Pr<span class="_ _3"></span>ovider<span class="ff2">&#65292;</span></span></span></span></div><div class="t m0 x2 h4 y5 ff2 fs2 fc0 sc0 ls0 ws0">&#20027;&#35201;&#29992;&#20110;&#24212;&#29992;&#31243;&#24207;&#24320;<span class="_ _3"></span>&#21457;&#26102;&#25552;&#20379;&#36328;&#36827;&#31243;&#25110;<span class="_ _3"></span>&#24212;&#29992;&#31243;&#24207;&#20869;&#37096;&#30340;&#36890;<span class="_ _3"></span>&#20449;&#65292;&#20248;&#28857;&#26159;&#25509;&#21475;&#31616;<span class="_ _3"></span>&#21333;&#65292;&#20351;&#29992;&#26041;&#20415;&#65292;</div><div class="t m0 x2 h4 y6 ff2 fs2 fc0 sc0 ls0 ws0">&#20294;&#20351;&#29992;&#26102;&#21487;&#33021;&#26377;<span class="_ _3"></span>&#19968;&#20123;&#23616;&#38480;&#24615;&#65292;<span class="_ _6"></span>&#27604;&#22914;&#24615;&#33021;&#21644;&#36820;<span class="_ _3"></span>&#22238;&#25968;&#25454;&#12290;<span class="_ _6"></span>&#36825;&#20123;&#26426;&#21046;&#24213;&#23618;&#21487;<span class="_ _3"></span>&#33021;&#20381;&#36182;<span class="_ _4"> </span><span class="ff1">Bin<span class="_ _3"></span>der<span class="ff2">&#12289;<span class="_ _7"></span><span class="ff1">ASH<span class="_"> </span><span class="ff2">&#26426;</span></span></span></span></div><div class="t m0 x2 h4 y7 ff2 fs2 fc0 sc0 ls0 ws0">&#21046;&#65292;&#23545;<span class="_ _2"></span>&#20110;&#24211;&#21644;&#26694;&#26550;<span class="_ _2"></span>&#23618;&#30340;&#24320;&#21457;<span class="_ _2"></span>&#20154;&#21592;&#26469;&#35828;<span class="_ _2"></span>&#20063;&#20250;&#26356;&#22810;&#30340;<span class="_ _2"></span>&#29992;&#21040;&#24213;&#23618;&#30340;<span class="_ _2"></span>&#26426;&#21046;&#65292;&#36825;<span class="_ _2"></span>&#20123;&#20869;&#23481;&#20250;&#25918;<span class="_ _2"></span>&#22312;&#21478;&#19968;&#31687;</div><div class="t m0 x2 h4 y8 ff2 fs2 fc0 sc0 ls0 ws0">&#12298;<span class="ff1">Andro<span class="_ _3"></span>id<span class="_ _4"> </span><span class="ff2">&#20869;&#26680;&#39537;&#21160;&#12299;<span class="_ _3"></span>&#20013;&#20171;&#32461;&#12290;<span class="ff1"> </span></span></span></div><div class="t m0 x2 h5 y9 ff4 fs3 fc0 sc0 ls0 ws0">6.1 <span class="_ _8"> </span><span class="ff5"> <span class="_ _9"> </span></span>Broadcast R<span class="_ _3"></span>ecei<span class="_ _3"></span>v<span class="_ _3"></span>er </div><div class="t m0 x2 h6 ya ff2 fs4 fc0 sc1 ls0 ws0">&#20160;&#20040;&#26159;<span class="_ _a"> </span><span class="ff3 sc0">Bro<span class="_ _3"></span>adcas<span class="_ _3"></span>t </span></div><div class="t m0 x2 h4 yb ff2 fs2 fc0 sc0 ls0 ws0">&#22312;<span class="_ _4"> </span><span class="ff1">andr<span class="_ _3"></span>o<span class="ls2">id<span class="_ _4"> </span></span><span class="ff2">&#20013;&#65292;<span class="_ _3"></span>&#36890;&#36807;&#24191;&#25773;<span class="_ _3"></span>&#65288;<span class="ff1">br<span class="_ _3"></span>oadcas<span class="_ _3"></span>t<span class="ff2">&#65289;<span class="_ _3"></span>&#21487;&#20197;&#36890;&#30693;&#20854;<span class="_ _3"></span>&#20182;&#24191;&#25773;&#25509;&#21463;&#32773;<span class="_ _3"></span>&#26576;&#20010;&#20107;&#20214;&#21457;&#29983;<span class="_ _3"></span>&#20102;&#12290;&#27604;<span class="_ _3"></span>&#22914;&#30005;&#28304;</span></span></span></span></div><div class="t m0 x2 h4 yc ff2 fs2 fc0 sc0 ls0 ws0">&#19981;&#36275;&#65292;<span class="_ _b"></span>&#20449;&#21495;&#19981;&#22909;&#31561;&#12290;<span class="_ _c"></span>&#39318;&#20808;&#65292;<span class="_ _c"></span>&#25105;&#20204;&#30475;&#19968;&#20010;&#31616;&#21333;&#30340;<span class="_ _4"> </span><span class="ff1">d<span class="_ _3"></span>emo<span class="ff2 ls3">&#65292;&#35813;<span class="_ _d"> </span></span>demo<span class="_"> </span><span class="ff2">&#23454;&#29616;&#20102;&#19968;&#20010;&#33258;<span class="_ _3"></span>&#23450;&#20041;<span class="_ _4"> </span><span class="ff1">br<span class="_ _3"></span>oadcas<span class="_ _3"></span>t<span class="ff2">&#12290;</span> </span></span></span></div><div class="t m0 x2 h7 yd ff1 fs2 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h4 ye ff2 fs2 fc0 sc0 ls0 ws0">&#21457;&#36865;&#31471;&#36825;&#20010;<span class="_ _a"> </span><span class="ff1">activit<span class="_ _3"></span>y<span class="_ _a"> </span><span class="ff2">&#20013;&#21019;&#24314;&#20102;&#19968;&#20010;<span class="_ _3"></span>&#25353;&#38062;&#65292;&#24403;&#25353;&#38062;<span class="_ _3"></span>&#34987;&#25353;&#19979;&#30340;&#26102;&#20505;&#36890;<span class="_ _3"></span>&#36807;<span class="_ _a"> </span><span class="ff1">sendBroad<span class="_ _3"></span>cas<span class="_ _3"></span>t()<span class="ff2">&#21457;&#36865;&#19968;&#20010;</span></span></span></span></div><div class="t m0 x2 h4 yf ff1 fs2 fc0 sc0 ls0 ws0">broadc<span class="_ _3"></span>ast<span class="ff2">&#12290;<span class="_ _3"></span><span class="ff1"> </span></span></div><div class="t m0 x2 h8 y10 ff6 fs0 fc0 sc0 ls0 ws0">public class BroadcastTest extends Activity { </div><div class="t m0 x2 h8 y11 ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span>public static final String NEW_LIFEFROM_DETECTED = </div><div class="t m0 x3 h8 y12 ff7 fs0 fc0 sc0 ls0 ws0">&#8220;<span class="ff6">com.android.broadcasttest.NEW_LIFEFROM</span>&#8221;<span class="ff6">; </span></div><div class="t m0 x2 h8 y13 ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span> </div><div class="t m0 x4 h8 y14 ff6 fs0 fc0 sc0 ls0 ws0">public void onCreate(Bundle savedInstanceState) { </div><div class="t m0 x2 h8 y15 ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span> <span class="_ _e"> </span><span class="ff7">&#8230;&#8230;</span> </div><div class="t m0 x2 h8 y16 ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span> <span class="_ _e"> </span>Button btn0 = (Button)findViewById(R.id.btn0); </div><div class="t m0 x2 h8 y17 ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span> <span class="_ _e"> </span>btn0.setOnClickListener(new OnClickListener() { </div><div class="t m0 x2 h8 y18 ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span> <span class="_ _e"> </span> <span class="_ _e"> </span>public void onClick(View v) { </div><div class="t m0 x2 h8 y19 ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span> <span class="_ _e"> </span> <span class="_ _e"> </span> <span class="_ _e"> </span>Intent it = new Intent(NEW_LIFEFROM_DETECTED); </div><div class="t m0 x2 h8 y1a ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span> <span class="_ _e"> </span> <span class="_ _e"> </span> <span class="_ _e"> </span>sendBroadcast(it); </div><div class="t m0 x2 h8 y1b ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span> <span class="_ _e"> </span> <span class="_ _e"> </span>} </div><div class="t m0 x2 h8 y1c ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span> <span class="_ _e"> </span>}); </div><div class="t m0 x4 h8 y1d ff6 fs0 fc0 sc0 ls0 ws0">} </div><div class="t m0 x4 h8 y1e ff7 fs0 fc0 sc0 ls0 ws0">&#8230;&#8230;<span class="ff6"> </span></div><div class="t m0 x2 h8 y1f ff6 fs0 fc0 sc0 ls0 ws0">} </div><div class="t m0 x2 h7 y20 ff1 fs2 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h4 y21 ff2 fs2 fc0 sc0 ls0 ws0">&#25509;&#25910;&#31471;&#22312;<span class="_ _4"> </span><span class="ff1">onR<span class="_ _3"></span>eceiv<span class="_ _3"></span>e()<span class="ff2">&#20013;&#23454;<span class="_ _3"></span>&#29616;&#20102;&#24403;&#25509;&#25910;&#21040;<span class="_ _4"> </span><span class="ff1">b<span class="_ _3"></span>roadc<span class="_ _3"></span>ast<span class="_"> </span><span class="ff2">&#25152;&#20570;&#30340;&#21160;&#20316;&#12290;</span> </span></span></span></div><div class="t m0 x2 h8 y22 ff6 fs0 fc0 sc0 ls0 ws0">Public class MyBroadcastReceiver extends BroadcastReceiver { </div><div class="t m0 x2 h8 y23 ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span><span class="ff7">&#8230;&#8230;</span> </div><div class="t m0 x2 h8 y24 ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span>Public void onReceive(Context context, Intene intent){ </div><div class="t m0 x2 h8 y25 ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span> <span class="_ _e"> </span>// TODO </div><div class="t m0 x2 h8 y26 ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span>} </div><div class="t m0 x2 h8 y27 ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span><span class="ff7">&#8230;&#8230;</span> </div><div class="t m0 x2 h8 y28 ff6 fs0 fc0 sc0 ls0 ws0">} </div><div class="t m0 x2 h7 y29 ff1 fs2 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h4 y2a ff2 fs2 fc0 sc0 ls0 ws0">&#22312;<span class="_ _4"> </span><span class="ff1">receiv<span class="_ _3"></span>er<span class="_"> </span><span class="ff2">&#30340;<span class="_ _4"> </span></span>action<span class="_"> </span><span class="ff2">&#20013;&#23450;&#20041;&#20102;&#35813;<span class="_ _4"> </span></span>r<span class="_ _3"></span>eceiver<span class="_"> </span><span class="ff2">&#33021;&#22815;&#25509;&#21463;<span class="_ _3"></span>&#30340;&#24191;&#25773;&#65292;<span class="ff1">Manif<span class="_ _3"></span>est<span class="_ _3"></span>.xml<span class="_"> </span><span class="ff2">&#23450;&#20041;&#37096;&#20998;&#65306;</span> </span></span></span></div><div class="t m0 x2 h8 y2b ff6 fs0 fc0 sc0 ls0 ws0">&lt;receiver android:name=<span class="ff7">&#8221;</span>.MyBroadcastReceiver<span class="ff7">&#8221;</span>&gt; </div><div class="t m0 x2 h8 y2c ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span>&lt;intent-filter&gt; </div><div class="t m0 x2 h8 y2d ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span> <span class="_ _e"> </span>&lt;action android:name=<span class="ff7">&#8221;</span>com.android.broadcasttest.NEW_LIFEFROM<span class="ff7">&#8221;</span> /&gt; </div><div class="t m0 x2 h8 y2e ff6 fs0 fc0 sc0 ls0 ws0"> <span class="_ _e"> </span>&lt;/intent-filter&gt; </div><div class="t m0 x2 h8 y2f ff6 fs0 fc0 sc0 ls0 ws0">&lt;/receiver&gt; </div></div><div class="pi" data-data='{"ctm":[1.611792,0.000000,0.000000,1.611792,0.000000,0.000000]}'></div></div></body></html>
评论
    相关推荐
    • android
      掌握Android Studio开发环境的搭建步骤,能够独立搭建 Android Studio开发环境
    • android
      android
    • android
      Android回购
    • android
      android
    • android课件
      清华老师上课的android课件。ch_01android概述ch_02android开发基础ch_03资源的访问ch_04android用户界面ch_05Ativity和Intent。其他自己看。
    • androidandroid
      androidandroidandroidandroidandroidandroidandroid
    • Android 教程
      Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android ...
    • Android
      Android
    • Android
      Android