How do you set up and run the samples in the Office 365 API Android SDK? This post provides a detailed step-by-step walkthrough. You can either read the post or watch the video, both of which cover the same content:
First, download the Office 365 SDK for Android from the GitHub repository. You can click on "Download Zip" on the page to download the SDK, or you can just press "Clone"
Open Android Studio, then go to File > Import Project. Look for the location you downloaded the SDK to, and go to the samples folder within that. Next, go into the folder "outlook" - I'm going to show you how to set up the "outlook" sample. Select build.gradle in this folder, and click OK.
At this point, Android Studio might prompt you "Language level changes will take effect on project reload. Would you like to reload project "outlook" now? Just click yes.
Your project structure should looks like this:
Press the Run button and run it on either your connected device or an emulator. You'll see that the app compiles and runs successfully, but it doesn't do anything.
What's wrong here? Well, we haven't yet registered this app with Azure Active Directory. Let's go do that now.
Go to Azure.com, and click on Portal at the top. Enter your login for Azure, and select your Active Directory that you want this app to be registered to. Let's say we want to test it on my clippy.onmicrosoft.com Office 365 tenant, so in this case, I select that tenant. You'll be able to select your own tenant here based on what you created previously.
Once you've select your Active Directory, click on "Applications" as shown below:
At the bottom, press "Add"
Select "Add an application my organization is developing" and on the next page, enter any name for your application. In this case, I'm using "Android-Outlook-Sample". Select "Native Client Application" since it's going to run on a mobile device.
On the next page, type anything you want into the Redirect URI box. I chose "https://www.google.com" as my redirect URI.
Press OK. Go to "Configure" and you'll see the following:
First we want to press the green "Add application" button below and select "Office 365 Exchange Online." Press OK, and select the following permission:
We just told Azure AD that we want this app to have some mail-specific permissions. So that means the app will be able to read and write a user's mail, and send mail as the user. Don't forget to click on "Save" at the bottom of the screen to save this change!
Now, go back to Android Studio and go to app > java > com.microsoft.services > samples.outlook > ServiceConstants.java in the project navigator view. Fill in the REDIRECT_URL and CLIENT_ID fields with the values in Azure AD (if you're not sure where to get these values, refer to the second-last image before this paragraph, that shows you where the redirect URL and client ID are). This is what you should have:
Now, run the app again. Immediately you see that you are presented with a login screen. Sign in to Office 365 with your credentials.
Click on "Play with Email"
You don't see anything yet. Tap on the three dots at the top right to bring up the menu, which contains of only one item, Settings. Tap on that and enter your email address. It should be the email address of the same user that you previously logged in to:
Press Enter, and then press "Update". If your mail doesn't show up, you might want to just tap on the Back Button to go back to the screen with the Mail & Calendar buttons, and tap on Mail again, and then hit update. It might take a while.
You should see your emails in your inbox show up!
Of course, you can also use the Calendar functionality in this sample, but you'll want to go into Azure AD first and add the relevant Calendar permissions. If you've any questions, post them in the Comments below.