package Ġcom . ans or od . inter apps 1 . ui Ċ Ċ import Ġandroid . content . Intent Ċ import Ġandroid . content . Intent Filter Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroid . os . Bundle Ċ import Ġcom . ans or od . inter apps 1 . R Ċ import Ġcom . ans or od . inter apps 1 . receiver . App 1 Broadcast Receiver Ċ import Ġkotlinx . android . synt hetic . main . activity _ main .* Ċ Ċ class ĠMainActivity Ġ: ĠAppCompatActivity () Ġ{ ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( R . layout . activity _ main ) ĊĊĠĠĠĠĠĠĠ Ġinit View () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġinit View () Ġ{ ĊĠĠĠĠĠĠĠ Ġsend Internal Button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsend Internal Broadcast () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġsend External Button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsend External Broadcast () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsend Internal Broadcast () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġintent Manifest Ġ= ĠIntent ( this , ĠApp 1 Broadcast Receiver :: class . java ) ĊĠĠĠĠĠĠĠ Ġintent Manifest . putExtra ( App 1 Broadcast Receiver . EXTRA _ MESSAGE , Ġ" This Ġis Ġan Ġordinary Ġmessage Ġsent Ġlocally Ġto Ġa ĠManifest Ġregistered Ġreceiver ") ĊĊĠĠĠĠĠĠĠ Ġval Ġintent Activity Ġ= ĠIntent ( App 1 Broadcast Receiver . ACTION ) ĊĠĠĠĠĠĠĠ Ġintent Activity . putExtra ( App 1 Broadcast Receiver . EXTRA _ MESSAGE , Ġ" This Ġis Ġan Ġordinary Ġmessage Ġsent Ġlocally Ġto Ġa ĠContext Ġregistered Ġreceiver ") ĊĊĠĠĠĠĠĠĠ Ġsend Broadcast ( intent Manifest ) ĊĠĠĠĠĠĠĠ Ġsend Broadcast ( intent Activity ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsend External Broadcast () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexternal Intent Ġ= ĠIntent (" com . ans or od . inter apps 2 . App 2 Broadcast Receiver . ACTION ") ĊĠĠĠĠĠĠĠ Ġexternal Intent .` package ` Ġ= Ġ" com . ans or od . inter apps 2 " ĊĠĠĠĠĠĠĠ Ġexternal Intent . putExtra (" EXTRA _ EXTERNAL _ MESSAGE ", Ġ" This Ġis Ġan Ġexternal Ġmessage ") ĊĊĠĠĠĠĠĠĠ Ġsend Broadcast ( external Intent ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġreceiver Ġ= ĠApp 1 Broadcast Receiver () ĊĊĠĠĠ Ġoverride Ġfun Ġon Resume () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Resume () ĊĊĠĠĠĠĠĠĠ Ġval Ġfilter Ġ= ĠIntent Filter ( App 1 Broadcast Receiver . ACTION ) ĊĊĠĠĠĠĠĠĠ Ġregister Receiver ( receiver , Ġfilter ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Pause () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Pause () ĊĊĠĠĠĠĠĠĠ Ġunregister Receiver ( receiver ) ĊĠĠĠ Ġ} Ċ }