You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/active-directory/develop/tutorial-v2-shared-device-mode.md
+51-25Lines changed: 51 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ ms.service: active-directory
9
9
ms.subservice: develop
10
10
ms.topic: tutorial
11
11
ms.workload: identity
12
-
ms.date: 1/15/2020
12
+
ms.date: 11/03/2022
13
13
ms.author: henrymbugua
14
14
ms.reviewer: brandwe
15
15
ms.custom: aaddev, identityplatformtop40
@@ -22,13 +22,14 @@ In this tutorial, Android developers and Azure Active Directory (Azure AD) tenan
22
22
In this tutorial:
23
23
24
24
> [!div class="checklist"]
25
-
> * Download a code sample
26
-
> * Enable and detect shared-device mode
27
-
> * Detect single or multiple account mode
28
-
> * Detect a user switch, and enable global sign-in and sign-out
29
-
> * Set up tenant and register the application in the Azure portal
30
-
> * Set up an Android device in shared-device mode
31
-
> * Run the sample app
25
+
>
26
+
> - Download a code sample
27
+
> - Enable and detect shared-device mode
28
+
> - Detect single or multiple account mode
29
+
> - Detect a user switch, and enable global sign-in and sign-out
30
+
> - Set up tenant and register the application in the Azure portal
31
+
> - Set up an Android device in shared-device mode
32
+
> - Run the sample app
32
33
33
34
## Prerequisites
34
35
@@ -64,21 +65,21 @@ Here's an example of the auth_config.json file included in the **app**>**main**>
64
65
65
66
```json
66
67
{
67
-
"client_id":"Client ID after app registration at https://aka.ms/MobileAppReg",
68
-
"authorization_user_agent":"DEFAULT",
69
-
"redirect_uri":"Redirect URI after app registration at https://aka.ms/MobileAppReg",
70
-
"account_mode":"SINGLE",
71
-
"broker_redirect_uri_registered": true,
72
-
"shared_device_mode_supported": true,
73
-
"authorities":[
74
-
{
75
-
"type":"AAD",
76
-
"audience":{
77
-
"type": "AzureADandPersonalMicrosoftAccount",
78
-
"tenant_id":"common"
79
-
}
80
-
}
81
-
]
68
+
"client_id":"Client ID after app registration at https://aka.ms/MobileAppReg",
69
+
"authorization_user_agent":"DEFAULT",
70
+
"redirect_uri":"Redirect URI after app registration at https://aka.ms/MobileAppReg",
71
+
"account_mode":"SINGLE",
72
+
"broker_redirect_uri_registered": true,
73
+
"shared_device_mode_supported": true,
74
+
"authorities":[
75
+
{
76
+
"type":"AAD",
77
+
"audience":{
78
+
"type": "AzureADandPersonalMicrosoftAccount",
79
+
"tenant_id":"common"
80
+
}
81
+
}
82
+
]
82
83
}
83
84
```
84
85
@@ -88,7 +89,7 @@ Shared-device mode allows you to configure Android devices to be shared by multi
88
89
89
90
Use `isSharedDevice()` to determine if an app is running on a device that is in shared-device mode. Your app could use this flag to determine if it should modify UX accordingly.
90
91
91
-
Here's a code snippet that shows how you could use `isSharedDevice()`. It's from the `SingleAccountModeFragment` class in the sample app:
92
+
Here's a code snippet that shows how you could use `isSharedDevice()`. It's from the `SingleAccountModeFragment` class in the sample app:
### Receive broadcast to detect global sign out initiated from other applications
209
+
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).
211
+
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.
215
+
216
+
```java
217
+
private static final String CURRENT_ACCOUNT_CHANGED_BROADCAST_IDENTIFIER = "com.microsoft.identity.client.sharedmode.CURRENT_ACCOUNT_CHANGED";
Any sign-ins and sign-outs on the device will be global, meaning they apply to all apps that are integrated with MSAL and Microsoft Authenticator on the device. You can now deploy applications to the device that use shared-device mode features.
286
+
Any sign-ins and sign-outs on the device will be global, meaning they apply to all apps that are integrated with MSAL and MicrosoftAuthenticator on the device. You can now deploy applications to the device that use shared-device mode features.
0 commit comments