The AWS Mobile SDK makes it easy for the app to directly access AWS services such as Amazon Lambda, S3, DynamoDB, Mobile Analytics, Machine Learning, Auto Scaling, etc. It supports iOS, Android, Xamarin, React Native, and Unity apps. In this article, we are mainly going to discuss steps to build AWS mobile app for Android using AWS Mobile SDK. The AWS Mobile SDK for Android is an open-source software development kit distributed under the Apache Open Source license. Amazon Web Services(AWS) is a Cloud services platform which provides a simple way to access servers, storage, databases and a broad set of application services over the Internet. It also owns and maintains the network-connected hardware required for these application services, while you provision and use what you need via a web application.
Steps to use AWS Mobile SDK in your Android mobile app
Step 1: Include the SDK in your AWS mobile app
There are two options to include the AWS mobile SDK in your project:
Option 1: Importing .jar file in the project from the link- Mobile SDK. Now you can drag .jar files for the individual services your project will use into the apps/libs
folder. They’ll be included on the build path automatically. Then, sync your project with the Gradle file.
Option 2: Importing gradle file into your Gradle.
dependencies { compile 'com.amazonaws:aws-android-sdk-core:2.2.+' compile 'com.amazonaws:aws-android-sdk-s3:2.2.+' compile 'com.amazonaws:aws-android-sdk-ddb:2.2.+' }
You can compile as much file your project needs. Then now sync your gradle.
Step 2: Set permission in your Manifest file of project
Add the following permission to your AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
Step 3: Get your AWS Credentials
Now the next step is to create an account in your AWS console. After creating an account in AWS Console you will get your authentication credentials. You can use it to access your AWS data in your app. For example, to access your EC2 like below:
AmazonEC2Client ec2Client = new AmazonEC2Client(getCredentials()); DescribeInstancesResult eC2value = ec2Client.describeInstances(); DescribeRegionsResult eCRegion = ec2Client.describeRegions();
Here getCredential() method returns the credentials provided by you to authenticate yourself. If the credentials will be authenticated you will get EC2 data otherwise it will throw an exception. In the same way, you can retrieve the other AWS resources like S3, DynamoDB, RDS etc.
You can also obtain AWS Credentials using Amazon Cognito Identity as your credential provider. Using a credentials provider allows your app to access AWS services without having to embed your private credentials in your application. This also allows you to set permissions to control which AWS services your users have access to.
To use Amazon Cognito, you must create an identity pool. An identity pool is a store of user identity data specific to your account. Every identity pool has configurable IAM roles that allow you to specify which AWS services your application’s users can access.
Conclusion
There are various advantages and benefits of AWS like- Trade capital expense for variables expense, benefit from massive economies of sales, increase in speed and agility etc. So after looking these all benefits having a mobile app to access the AWS resources can be proved to be very helpful and important. To use the AWS Mobile SDK in your AWS mobile app is quite easy. I hope this article would help to start your project to use AWs data in your app :-).
References
AWS : It features various types of resources to help us learn about the services and features AWS has to offer and get started with building our solutions faster.
AWS Mobile SDK: It includes libraries, code samples, and documentation for different mobiles platforms so we can build apps that deliver great experiences across devices and platforms.