This client library is a release candidate and is still in preview status, please continue to provide feedback as we iterate towards a production supported library.
Integrate the Microsoft Graph API into your Android application!
Add the maven central repository to your projects build.gradle file then add a compile dependency for com.microsoft.graph:msgraph-sdk-android:0.9.+
repository {
jcenter()
}
dependency {
// Include the sdk as a dependency
compile('com.microsoft.graph:msgraph-sdk-android:0.9.+')
// Include the gson dependency
compile('com.google.code.gson:gson:2.3.1')
}
Register your application by following these steps.
An instance of the GraphServiceClient class handles building requests,
sending them to Microsoft Graph API, and processing the responses. To create a
new instance of this class, you need to provide an instance of
IAuthenticationProvider
which can authenticate requests to Microsoft Graph.
For an example of authentication in a client application see the MSGraph SDK Android MSA Auth for Android Adapter.
Once you have set the correct application Id and url, you must get a GraphServiceClient object to make requests against the service. The SDK will store the account information for you, but when a user logs on for the first time, it will invoke UI to get the user's account information.
final IClientConfig mCLientConfig = DefaultClientConfig.createWithAuthenticationProvider(mAuthenticationProvider);
final IGraphServiceClient mClient = new GraphServiceClient
.Builder()
.fromConfig(mClientConfig)
.buildClient();
Once you have an GraphServiceClient that is authenticated you can begin making calls against the service. The requests against the service look like our REST API.
To retrieve a user's drive:
graphClient
.getMe()
.getDrive()
.buildRequest()
.get(new ICallback<Drive>() {
@Override
public void success(final Drive result) {
final String msg = "Found Drive " + result.id;
Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT)
.show();
}
...
// Handle failure case
});
For a general overview of how the SDK is designed, see overview.
For a more detailed documentation see:
For known issues, see issues.
The Microsoft Graph SDK is open for contribution. Please read how to contribute to this project here.
The Microsoft Graph SDK for Android library is supported at runtime for Android API revision 15 and greater. To build the sdk you need to install Android API revision 23 or greater.
Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT license.
[Third Party Notices](THIRD PARTY NOTICES)