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
{{ message }}
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
# Connect Sample for Android Using the Microsoft Graph SDK
22
-
23
-
24
-
>**Note:** We've updated this sample to use the [Microsoft Authentication Library (MSAL)](https://github.com/AzureAD/microsoft-authentication-library-for-android) for Android apps.
25
-
26
-
27
-
> **Building apps for enterprise customers?** Your app may not work if your enterprise customer turns on enterprise mobility security features like <ahref="https://azure.microsoft.com/en-us/documentation/articles/active-directory-conditional-access-device-policies/"target="_newtab">conditional device access</a>. In this case, you may not know and your customers may experience errors.
28
-
29
-
> To support **all enterprise customers** across **all enterprise scenarios**, you must use the Azure AD endpoint and manage your apps using the [Azure Management Portal](https://aka.ms/aadapplist). For more information, see [Deciding between the Azure AD and Azure AD v2.0 endpoints](https://graph.microsoft.io/docs/authorization/auth_overview#deciding-between-azure-ad-and-the-v2-authentication-endpoint).
30
-
31
-
[](https://www.youtube.com/watch?v=3IQIDFrqhY4"Click to see the sample in action")
32
-
33
-
Connecting to Microsoft Graph is the first step every Android app must take to start working with Office 365 services and data. This sample shows how to connect and then call one API through the Microsoft Graph SDK.
34
-
35
-
## Device requirements
36
-
37
-
To run the Connect sample, your device needs to meet the following requirements:
38
-
39
-
* A screen size of 800 x 480 or larger.
40
-
* Android API level 16 or higher.
41
-
42
-
## Prerequisites
43
-
44
-
To use the Connect sample for Android, you need the following:
45
-
46
-
*[Android Studio](http://developer.android.com/sdk/index.html) version 1.0 or later.
47
-
*[Java Development Kit (JDK) 7](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html).
48
-
49
-
<aname="register"></a>
50
-
## Register and configure the app
51
-
52
-
1. Open a browser and navigate to the [Azure Active Directory admin center](https://aad.portal.azure.com). Login using a **Work or School Account**.
53
-
54
-
1. Select **Azure Active Directory** in the left-hand navigation, then select **App registrations (Preview)** under **Manage**.
55
-
56
-

57
-
58
-
1. Select **New registration**. On the **Register an application** page, set the values as follows.
59
-
60
-
- Set a preferred **Name** e.g. `AndroidJavaConnect`
61
-
- Set **Supported account types** to **Accounts in any organizational directory**.
62
-
63
-

64
-
65
-
1. Choose **Register**. On the **AndroidJavaConnect** app page, select **Overview** and copy the value of the **Application (client) ID** and save it, you will need it in the next step.
66
-
67
-

68
-
69
-
1. Still on the app page, select **Authentication**. Locate the section **Redirect URIs**. In the _Suggested Redirect URIs for public clients(mobile,desktop)_, check the second box so that the app can work with the MSAL libraries used in the application. (The box should contain the option _msal<YOUR_CLIENT_ID>://auth_). Choose **Save**.
70
-
71
-

72
-
73
-
To learn about authenticating with MSAL for Android to make calls to Microsoft Graph, see [Call the Microsoft Graph API from an Android app](https://docs.microsoft.com/en-us/azure/active-directory/develop/guidedsetups/active-directory-android).
74
-
75
-
76
-
## Open the sample using Android Studio
77
-
78
-
1. Install [Android Studio](http://developer.android.com/sdk/index.html) and add the Android SDK packages according to the [instructions](http://developer.android.com/sdk/installing/adding-packages.html) on developer.android.com.
79
-
2. Download or clone this sample.
80
-
4. Start Android Studio.
81
-
1. Close any projects that you might have open, and then choose **Open an existing Android Studio project**.
82
-
2. Browse to your local repository and choose the Android-Connect project. Click **OK**.
83
-
84
-
> Note: Android Studio shows a **Frameworks detected** notification if you don't have the **Android Support Repository** installed. Open the SDK manager and add the Android Support Repository to avoid the Frameworks detected notification.
85
-
5. Open AndroidManifest.xml
86
-
* Replace *ENTER_YOUR_CLIENT_ID* in two places with the application id from the previous section.
87
-
6. Build the app and install the .APK on your device or emulator.
88
-
7. Enable the **Storage** permission for the installed sample app on your device or emulator
89
-
8. Download the test.jpg image located in: `android-java-connect-sample/app/src/main/res/drawable/test.jpg` to your device's external storage root folder.
90
-
91
-
92
-
93
-
Once you've built the Connect sample, you can run it on an emulator or device. Pick a device with API level 16 or higher from the **Choose device** dialog.
94
-
95
-
To learn more about the sample, see [Call Microsoft Graph in an Android app](https://developer.microsoft.com/en-us/graph/docs/concepts/android).
96
-
97
-
<aname="contributing"></a>
98
-
## Contributing ##
99
-
100
-
If you'd like to contribute to this sample, see [CONTRIBUTING.MD](/CONTRIBUTING.md).
101
-
102
-
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
103
-
104
-
## Questions and comments
105
-
106
-
We'd love to get your feedback about the Connect sample. You can send your questions and suggestions to us in the [Issues](issues) section of this repository.
107
-
108
-
Questions about Microsoft Graph development in general should be posted to [Stack Overflow](http://stackoverflow.com/questions/tagged/MicrosoftGraph+API). Make sure that your questions or comments are tagged with [MicrosoftGraph] and [API].
109
-
110
-
## Next steps
111
-
112
-
This sample just shows the essentials that your apps need to work with Microsoft Graph. There is so much more that your apps can do using the Office 365 APIs, like helping your users to manage their work day with calendar, find just the information they need in all the files they store in OneDrive, or find the exact person they need from their list of contacts. We have more to share with you in the [Snippets sample for Android](../../../android-java-snippets-sample).
113
-
114
-
## Additional resources
115
-
116
-
*[Get started with Office 365 APIs powered by Microsoft Graph](http://dev.office.com/getting-started/office365apis)
*[Microsoft Graph SDK for Android](../../../msgraph-sdk-android)
119
-
*[Snippets sample for Android](../../../android-java-snippets-sample)
120
-
121
-
## Copyright
122
-
Copyright (c) 2019 Microsoft. All rights reserved.
21
+
# Connect Sample for Android Using the Microsoft Graph SDK
22
+
23
+
24
+
>**Note:** We've updated this sample to use the [Microsoft Authentication Library (MSAL)](https://github.com/AzureAD/microsoft-authentication-library-for-android) for Android apps.
25
+
26
+
27
+
> **Building apps for enterprise customers?** Your app may not work if your enterprise customer turns on enterprise mobility security features like <ahref="https://azure.microsoft.com/en-us/documentation/articles/active-directory-conditional-access-device-policies/"target="_newtab">conditional device access</a>. In this case, you may not know and your customers may experience errors.
28
+
29
+
> To support **all enterprise customers** across **all enterprise scenarios**, you must use the Azure AD endpoint and manage your apps using the [Azure Management Portal](https://aka.ms/aadapplist). For more information, see [Deciding between the Azure AD and Azure AD v2.0 endpoints](https://graph.microsoft.io/docs/authorization/auth_overview#deciding-between-azure-ad-and-the-v2-authentication-endpoint).
30
+
31
+
[](https://www.youtube.com/watch?v=3IQIDFrqhY4"Click to see the sample in action")
32
+
33
+
Connecting to Microsoft Graph is the first step every Android app must take to start working with Office 365 services and data. This sample shows how to connect and then call one API through the Microsoft Graph SDK.
34
+
35
+
## Device requirements
36
+
37
+
To run the Connect sample, your device needs to meet the following requirements:
38
+
39
+
* A screen size of 800 x 480 or larger.
40
+
* Android API level 16 or higher.
41
+
42
+
## Prerequisites
43
+
44
+
To use the Connect sample for Android, you need the following:
45
+
46
+
*[Android Studio](http://developer.android.com/sdk/index.html) version 1.0 or later.
47
+
*[Java Development Kit (JDK) 7](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html).
48
+
49
+
<aname="register"></a>
50
+
## Register and configure the app
51
+
52
+
1. Open a browser and navigate to the [Azure Active Directory admin center](https://aad.portal.azure.com). Login using a **Work or School Account**.
53
+
54
+
1. Select **Azure Active Directory** in the left-hand navigation, then select **App registrations (Preview)** under **Manage**.
55
+
56
+

57
+
58
+
1. Select **New registration**. On the **Register an application** page, set the values as follows.
59
+
60
+
- Set a preferred **Name** e.g. `AndroidJavaConnect`
61
+
- Set **Supported account types** to **Accounts in any organizational directory**.
62
+
63
+

64
+
65
+
1. Choose **Register**. On the **AndroidJavaConnect** app page, select **Overview** and copy the value of the **Application (client) ID** and save it, you will need it in the next step.
66
+
67
+

68
+
69
+
1. Still on the app page, select **Authentication**. Locate the section **Redirect URIs**. In the _Suggested Redirect URIs for public clients(mobile,desktop)_, check the second box so that the app can work with the MSAL libraries used in the application. (The box should contain the option _msal<YOUR_CLIENT_ID>://auth_). Choose **Save**.
70
+
71
+

72
+
73
+
To learn about authenticating with MSAL for Android to make calls to Microsoft Graph, see [Call the Microsoft Graph API from an Android app](https://docs.microsoft.com/en-us/azure/active-directory/develop/guidedsetups/active-directory-android).
74
+
75
+
76
+
## Open the sample using Android Studio
77
+
78
+
1. Install [Android Studio](http://developer.android.com/sdk/index.html) and add the Android SDK packages according to the [instructions](http://developer.android.com/sdk/installing/adding-packages.html) on developer.android.com.
79
+
2. Download or clone this sample.
80
+
4. Start Android Studio.
81
+
1. Close any projects that you might have open, and then choose **Open an existing Android Studio project**.
82
+
2. Browse to your local repository and choose the Android-Connect project. Click **OK**.
83
+
84
+
> Note: Android Studio shows a **Frameworks detected** notification if you don't have the **Android Support Repository** installed. Open the SDK manager and add the Android Support Repository to avoid the Frameworks detected notification.
85
+
5. Open AndroidManifest.xml
86
+
* Replace *ENTER_YOUR_CLIENT_ID* in two places with the application id from the previous section.
87
+
6. Build the app and install the .APK on your device or emulator.
88
+
7. Enable the **Storage** permission for the installed sample app on your device or emulator
89
+
8. Download the test.jpg image located in: `android-java-connect-sample/app/src/main/res/drawable/test.jpg` to your device's external storage root folder.
90
+
91
+
92
+
93
+
Once you've built the Connect sample, you can run it on an emulator or device. Pick a device with API level 16 or higher from the **Choose device** dialog.
94
+
95
+
To learn more about the sample, see [Call Microsoft Graph in an Android app](https://developer.microsoft.com/en-us/graph/docs/concepts/android).
96
+
97
+
<aname="contributing"></a>
98
+
## Contributing ##
99
+
100
+
If you'd like to contribute to this sample, see [CONTRIBUTING.MD](/CONTRIBUTING.md).
101
+
102
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
103
+
104
+
## Questions and comments
105
+
106
+
We'd love to get your feedback about the Connect sample. You can send your questions and suggestions to us in the [Issues](issues) section of this repository.
107
+
108
+
Questions about Microsoft Graph development in general should be posted to [Stack Overflow](http://stackoverflow.com/questions/tagged/MicrosoftGraph+API). Make sure that your questions or comments are tagged with [MicrosoftGraph] and [API].
109
+
110
+
## Next steps
111
+
112
+
This sample just shows the essentials that your apps need to work with Microsoft Graph. There is so much more that your apps can do using the Office 365 APIs, like helping your users to manage their work day with calendar, find just the information they need in all the files they store in OneDrive, or find the exact person they need from their list of contacts. We have more to share with you in the [Snippets sample for Android](../../../android-java-snippets-sample).
113
+
114
+
## Additional resources
115
+
116
+
*[Get started with Office 365 APIs powered by Microsoft Graph](http://dev.office.com/getting-started/office365apis)
0 commit comments