Learn Spring for Android Application Development
eBook - ePub

Learn Spring for Android Application Development

Build robust Android applications with Kotlin 1.3 and Spring 5

  1. 392 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learn Spring for Android Application Development

Build robust Android applications with Kotlin 1.3 and Spring 5

About this book

A hands-on guide to Android programming with Spring MVC, Spring Boot, and Spring Security

Key Features

  • Build native Android applications with Spring for Android
  • Explore Reactive programming, concurrency, and multithreading paradigms for building fast and efficient applications
  • Write more expressive and robust code with Kotlin using its coroutines and other latest features

Book Description

As the new official language for Android, Kotlin is attracting new as well as existing Android developers. As most developers are still working with Java and want to switch to Kotlin, they find a combination of these two appealing. This book addresses this interest by bringing together Spring, a widely used Java SE framework for building enterprise-grade applications, and Kotlin.

Learn Spring for Android Application Development will guide you in leveraging some of the powerful modules of the Spring Framework to build lightweight and robust Android apps using Kotlin. You will work with various modules, such as Spring AOP, Dependency Injection, and Inversion of Control, to develop applications with better dependency management. You'll also explore other modules of the Spring Framework, such as Spring MVC, Spring Boot, and Spring Security. Each chapter has practice exercises at the end for you to assess your learning.

By the end of the book, you will be fully equipped to develop Android applications with Spring technologies.

What you will learn

  • Get to grips with the basics of the Spring Framework
  • Write web applications using the Spring Framework with Kotlin
  • Develop Android apps with Kotlin
  • Connect a RESTful web service with your app using Retrofilt
  • Understand JDBC, JPA, MySQL for Spring and SQLite Room for Android
  • Explore Spring Security fundamentals, Basic Authentication, and OAuth2
  • Delve into Concurrency and Reactive programming using Kotlin
  • Develop testable applications with Spring and Android

Who this book is for

If you're an aspiring Android developer or an existing developer who wants to learn how to use Spring to build robust Android applications in Kotlin, this book is for you. Though not necessary, basic knowledge of Spring will assist with understanding key concepts covered in this book.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

Creating an Application

So far, we have prepared you to become a professional Spring-based developer. You have learned what Spring is, as well as the functions of its architecture, components, security features, database, and so on. We have also shown you how to develop an Android app and handle HTTP requests and use the database.
As you know, we developed all the example projects in Kotlin, and nowadays, this language is very famous among developers for its conciseness and interoperability. In this chapter, we will implement all the features of the previous chapters to develop a project that will have a server and a client side.
This chapter covers the following topics:
  • Project idea
  • Creating the design
  • Server side:
    • Developing a database model
    • Creating a project and Maven dependency
    • Creating entities, repositories, and a controller
    • Implementing security
    • Modified application.properties
  • Client side:
    • Creating models
    • Creating HTTP requests
    • Creating API services
    • Modifying activities
    • Fetching REST APIs
    • Creating an adapter and XML layouts
    • Checking the output

Technical requirements

You will need almost all the dependencies, such as security, MySQL, JPA, Hibernate, and JDBC, from the previous chapters.
The source code with an example for this chapter is available on GitHub at the following link: https://github.com/PacktPublishing/Learn-Spring-for-Android-Application-Development/tree/master/Chapter09.
You will find two projects—social_network is the server side, which has been developed with the help of the Spring Framework, and ClientSide is the client side, which has been developed for the Android platform.

Project idea

The project idea is the most important part. You need to generate this idea very carefully and have to identify the facts behind your project. You need to keep in mind how this project could be effective on the market, how the users will accept your project, why they will use it, why they should choose your app instead of others, what features will make it different from other existing similar projects, and so on. After generating an idea, you need to create a draft in your mind of how will it look. Then you need to put it down on paper, design the workflow of the project, and then develop the project's code. Lastly, you need to test the project for its smoothness, check that it's bug/error free, and prepare it for the market.
In this chapter, we will create a small project that is like a social network. We will name it Packt Network. This project will have two parts. One is a server and one is a client, and both sides will be written in Kotlin. First of all, we create a Spring project where we will build our server and REST API. The data will be stored in a MySQL database, and we will handle the database using JDBC, JPA, and Hibernate. This data will be protected by the basic authentication of Spring Security.
In our second project, we will create an Android application and handle the created REST APIs of the server. We will use Retrofit to handle the REST APIs and the network. Then we will create a registration and login page to create and login as a user, using a username and password. After this, the user can post a status and see a list of all the other user's statuses. A comment can be also posted in a status.
Now we will start to design and develop our server-side project using Spring.

Server side

On the server side, we are using the Spring Framework. We will handle all the data with a MySQL database and protect the resources with basic authentication.
First of all, we will design the project's backend logic. Then we will plan for the REST API. We will create a data model using MySQL Workbench. Then we will create the project using http://start.spring.io. Then we will create the database e...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. Dedication
  4. About Packt
  5. Contributors
  6. Preface
  7. About the Environment
  8. Overview of Kotlin
  9. Overview of Spring Framework
  10. Spring Modules for Android
  11. Securing Applications with Spring Security
  12. Accessing the Database
  13. Concurrency
  14. Reactive Programming
  15. Creating an Application
  16. Testing an Application
  17. Assessments
  18. Other Books You May Enjoy

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Learn Spring for Android Application Development by S. M. Mohi Us Sunnat, Igor Kucherenko in PDF and/or ePUB format, as well as other popular books in Computer Science & Open Source Programming. We have over one million books available in our catalogue for you to explore.