简体   繁体   中英

Receiver's Lifecycle

I have two applications which talk with each other via receiver. When a button is pressed in application A, I broadcast an Intent with a certain permission. Application B then wakes up makes some calculations and again broadcasts an Intent with a certain permission for application A. In both manifests I define the permission (same name) and I also register both receivers.

    <permission android:name="aa.bb.cc.dd"
    android:label="permission"
    android:protectionLevel="normal"></permission>

    <receiver android:name=".receiver"
        android:exported="true">

        <uses-permission android:name="aa.bb.cc.dd"/>

        <intent-filter>
            <action android:name= "a_certain_action"/>/>
        </intent-filter>
    </receiver>

and call them :

    Intent i = new Intent();
    i.setAction("a_certain_action");
    sendBroadcast(i,"aa.bb.cc.dd");

However while this worked perfect yesterday today the receiver on application B won't wake up when I broadcast the intent. Why is that?

Your app was probably killed, and receiver is unregistered then. Try to use service, and there register broadcast

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM