Skip to content

Commit f8d9f56

Browse files
[msid] adding broadcast section
1 parent e4fe08b commit f8d9f56

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

articles/active-directory/develop/tutorial-v2-shared-device-mode.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.service: active-directory
99
ms.subservice: develop
1010
ms.topic: tutorial
1111
ms.workload: identity
12-
ms.date: 10/25/2022
12+
ms.date: 11/03/2022
1313
ms.author: henrymbugua
1414
ms.reviewer: brandwe
1515
ms.custom: aaddev, identityplatformtop40
@@ -205,27 +205,29 @@ private void onSignOutClicked()
205205
}
206206
```
207207

208-
To receive the account change broadcast, you'll need to register a broadcast receiver.  It’s recommended to register your broadcast receiver via the Context. For more information about Context, see [Context-registered receivers](https://developer.android.com/guide/components/broadcasts#context-registered-receivers)
208+
### Receive broadcast to detect global sign out initiated from other applications
209209

210-
When an account change broadcast is received, immediately get the signed in user and determine if a user has changed on the device. If a change is detected, initiate data cleanup for previously signed-in account. It is recommended to properly stop any operations and do data cleanup.
210+
To receive the account change broadcast, you'll need to register a broadcast receiver.  It’s recommended to register your broadcast receiver via the [Context-registered receivers](https://developer.android.com/guide/components/broadcasts#context-registered-receivers).
211211
212-
The following code snippet shows how you could register a broadcast receiver.
212+
When an account change broadcast is received, immediately [get the signed in user and determine if a user has changed on the device](#get-the-signed-in-user-and-determine-if-a-user-has-changed-on-the-device). If a change is detected, initiate data cleanup for previously signed-in account. It is recommended to properly stop any operations and do data cleanup.
213+
214+
The following code snippet shows how you could register a broadcast receiver.
213215
214216
```java
215-
private static final String CURRENT_ACCOUNT_CHANGED_BROADCAST_IDENTIFIER = "com.microsoft.identity.client.sharedmode.CURRENT_ACCOUNT_CHANGED";
216-
private BroadcastReceiver mAccountChangedBroadcastReceiver;
217-
private void registerAccountChangeBroadcastReceiver(){
218-
    mAccountChangedBroadcastReceiver = new BroadcastReceiver() {
219-
        @Override
220-
        public void onReceive(Context context, Intent intent) {
221-
            //INVOKE YOUR PRIOR ACCOUNT CLEAN UP LOGIC HERE      
222-
        }
223-
    };
224-
    IntentFilter filter = new
225-
226-
IntentFilter(CURRENT_ACCOUNT_CHANGED_BROADCAST_IDENTIFIER);
227-
    this.registerReceiver(mAccountChangedBroadcastReceiver, filter);
228-
}
217+
private static final String CURRENT_ACCOUNT_CHANGED_BROADCAST_IDENTIFIER = "com.microsoft.identity.client.sharedmode.CURRENT_ACCOUNT_CHANGED";
218+
private BroadcastReceiver mAccountChangedBroadcastReceiver;
219+
private void registerAccountChangeBroadcastReceiver(){
220+
    mAccountChangedBroadcastReceiver = new BroadcastReceiver() {
221+
        @Override
222+
        public void onReceive(Context context, Intent intent) {
223+
            //INVOKE YOUR PRIOR ACCOUNT CLEAN UP LOGIC HERE      
224+
        }
225+
    };
226+
    IntentFilter filter = new
227+
228+
IntentFilter(CURRENT_ACCOUNT_CHANGED_BROADCAST_IDENTIFIER);
229+
    this.registerReceiver(mAccountChangedBroadcastReceiver, filter);
230+
}
229231
```
230232
231233
## Administrator guide
@@ -299,5 +301,5 @@ The Sample Application is a simple app that will call the Graph API of your orga
299301

300302
Learn more about working with the Microsoft Authentication Library and shared device mode on Android devices:
301303

302-
> [!div class="nextstepaction"]
304+
> [!div class="nextstepaction"]
303305
> [Shared device mode for Android devices](msal-android-shared-devices.md)

0 commit comments

Comments
 (0)