How to run and test an Android App on a Virtual Device?

In the last tutorial you learned how to build a basic Android App using Android Studio. Once you have created the App how can you test it ? Or how can you run it ?

For this we use the Emulator which comes with Android SDK. It simulates a real world Android Device. Alternatively if you have an Android device like a smartphone then you can run the app on that as well. It’s fairly easy.

Let’s look at how to use the Emulator. Please refer to the below video to understand the steps needed.

To get started you will have to setup Android Virtual Device in the Android Studio. For this open the Android Virtual Device Manager from Android Studio. You can setup multiple Virtual Devices and use any of them to run the App as long as it’s compatible.

In the next tutorial we will see what happens behind the scene when you run the App.

Project Structure and Key files in the Android App Project

In the earlier tutorial we created an Android App Project using the Android Studio. In this video tutorial we look at the key files which are part of the Android Project.

We look at the Activity file, the layout file and also talk about the role of Gradle which helps build and deploy the App.

Android App Development Basics | Install Android Studio | Activities and Layouts

Key Concepts

  1. Activities
    We use Activity to define what the App does. Like when we click on a button what needs to happen can be defined using an Activity. It’s a class written in Kotlin.
  2. Layouts
    To define how a screen in your App will look like we use an XML file. A screen can have various elements like images, text etc.

We use Layouts to define the UI and Activities to define the behaviour. Similar to what we do with websites – HTML, CSS and Javascript.

Like if you need to add a button then we use Layout to specify its position on screen and Activity to add functionality.

We bundle all these files together and that’s what an App is.

What happens when you start an App ?

Sequence of events when you start an Android App

  1. When you start an Android App the main activity is called.
  2. This tells Android to use a particular Layout.
  3. The layout is displayed on the device.
  4. The user interacts with the layout.
  5. The activity responds to these interactions, and updates the display.

Why Kotlin ?
It’s preferred because of additional features and it’s concise nature.

Why Android Studio ?
It includes a set of code editors, UI tools and templates, which are all designed to make development easier and faster.
It also comes with Android SDK which is needed to develop Apps. It includes Android source code and also a compiler to compile the code you write to Android format.

Getting Started

Install Android Studio from https://developer.android.com/studio

Build the App – follow the video

  1. Create a new project
  2. Select a project template – Choose the Empty Activity option.
  3. Configure the project – Specify the app name, package name and save location. Be careful with the version you select. We will discuss more on this in future blog, but you need to consider which versions of Android you want the app to be compatible with. If you specify that the app is only compatible with the very latest version of the SDK, you might find that it can’t be run on many devices.

That is it, your first app is ready. Congratulations !!

Tech Stack for Native Android Development

What is a Native Android App ?

When your App is built to run on Android devices only. The advantages of building a Native app includes high performance, access to native APIs and features and better user experience. The disadvantages may include longer development time, higher development costs and platform-specific development.

What Tools and Technologies can be used to build a Native Android App ?

For native Android development, you can use the following tools and technologies

  1. Java or Kotlin programming languages – Both Java and Kotlin are popular programming languages for Android development. While Java has been the traditional language for Android development, Kotlin is gaining popularity due to its concise syntax and modern features.
  2. Android Studio – Android Studio is the official Integrated Development Environment (IDE) for Android app development. It comes with a set of tools and features that simplify the development process and speed up app development.
  3. Android SDK – The Android SDK is a collection of software development tools and libraries required for building Android apps. It includes tools for developing, debugging, and testing Android apps.
  4. Android Jetpack – Android Jetpack is a set of libraries and tools that help developers build high-quality apps faster. It includes components for handling UI, background processing, navigation, and more.
  5. Firebase – Firebase is a mobile and web application development platform that provides a range of features and services to simplify the app development process, such as real-time databases, push notifications, authentication, and analytics.
  6. Third-party libraries – There are various third-party libraries and tools available for Android development that can help you add functionality to your app or speed up development. Some popular ones include Retrofit for network communication, Glide for image loading and caching, and Dagger for dependency injection.

These are some of the most commonly used tools and technologies for native Android development. You can use them to create high-quality and feature-rich Android apps.

Steps to create a Native Android App

Let’s look at the steps to create a simple Native Android App

  1. Set up your development environment: To develop native Android apps, you’ll need to download and install Android Studio, which is the official IDE for Android development. Android Studio comes with the Android SDK and all the necessary tools you need to build and test your app.
  2. Create a new Android project: After setting up your development environment, create a new Android project in Android Studio. This will generate a default app structure with a basic user interface.
  3. Design the user interface: Android Studio comes with a visual layout editor that allows you to drag and drop UI elements onto the screen and customize their properties. Use this editor to create the user interface for your app, and add functionality to the UI elements by writing code in Java or Kotlin.
  4. Write your app logic: Once you’ve designed the user interface, write the code that handles user interactions and performs the necessary tasks to make your app work. This might include retrieving data from a database or web service, processing user input, or manipulating media files.
  5. Test your app: After you’ve finished writing your app, test it on a physical Android device or an emulator to ensure that it works as expected. Android Studio comes with a built-in emulator that allows you to test your app on various Android versions and device configurations.
  6. Publish your app: Once you’ve tested your app and made any necessary changes, you can publish it on the Google Play Store, which is the official app store for Android. To publish your app, you’ll need to create a developer account, submit your app for review, and follow Google’s guidelines for app publishing.

Which Tech Stack can be used to create an Android App

There are various tech stacks you can use to build an Android App. The choice depends on the requirements, skills and preferences.

Here are some popular options

  1. Native Android Development
    This approach uses Java or Kotlin programming languages, Android Studio, and the Android SDK to create high-performance, feature-rich, and user-friendly apps for Android devices. This is the recommended approach for building complex and feature-rich apps that require optimal performance and integration with the platform.
  2. Hybrid App Development
    This approach uses web technologies such as HTML, CSS, and JavaScript to create cross-platform apps that can run on multiple platforms, including Android. Popular hybrid app development frameworks include React Native, Ionic, and Xamarin.
  3. Progressive Web Apps (PWA)
    PWAs use web technologies to create app-like experiences that can run on any device with a web browser, including Android devices. PWAs offer benefits such as offline capabilities, push notifications, and access to device features like camera and microphone.

As you can see, the best tech stack for your Android app depends on the specific requirements of your project.

You should consider factors such as development time, performance, scalability, maintainability, and user experience when making your decision.

In the next article we dive more into “Native Android Development” tech stack.

India to soon introduce next-gen ePassport for citizens with a microchip

Sanjay Bhattacharya from Ministry of External Affairs, took to Twitter to inform them that India would soon get e-passports with secure biometric data.

  • The passport would contain secure biometric data.
  • It would ensure smooth passage through immigration posts globally.
  • The e-passport would be ICAO compliant.
  • And would be produced at India Security Press, Nashik

What is an e-passport?

  • e-passport will be a replacement for the traditional passport. It will have an electronic chip that carries the same information as the printed passport like name, date of birth etc.
  • The e-passport could be scanned, which will speed up the verification process at the immigration counter.
  • It will also help curb the fake passport business. Any tampering with microchip will result in failure of passport authentication.

UltraRAM – The Next Big Thing in Storage

What is UltraRAM ?

UltraRAM combines RAM and Storage into one ultrafast memory solution.

The Research

We know that pretty much everyone is exploring how to combine both memory and data. Guess what, researchers at Lancaster University have found a way to make this happen.

Their paper highlights a breakthrough in the mass production of UltraRAM.

UltraRAM is a type of memory that offers RAM and SSD storage combined to provide you with the fastest storage solution possible. It doesn’t release data when turned off and can combine RAM chips with hard drives for a seamless effect.

It’s a non-volatile memory that does not require power to store data and it has the same speeds as DRAM when in use.

So it can lead to a 1-stop solution for RAM and storage by combing them together in a single device. Which means in future when you buy a 1TB UltraRAM device, it will be able to function as both storage and RAM.

Gentle Introduction to Prototypes and Prototypal Inheritance in Javascript

In this short video tutorial I will explain in simple terms what are prototypes in Javascript and how Inheritance works.

Key points to keep in mind

  • In Javascript if an object wants to inherit from another object then it can do so using prototypal inheritance.
  • The parent object is referred to as Prototype.
  • __proto__ is deprecated, we can use Object.create()
let fourWheelerObj = {tyres: 4} // Prototype

let carObjectOne = {engine: 'v6', __proto__: fourWheelerObj}

console.log(carObjectOne.tyres) // 4


let carObjectTwo = Object.create(fourWheelerObj)
console.log(carObjectTwo.tyres) // 4

Learn about Javascript Strings

We will learn how to create Strings, escaping quotes and string concatenation.

Code examples below are also available at Github

Creating a String
Strings are surrounded by quotation marks. It can be single or double quotes.
Just like we declare and initialize numbers we can work with strings.

let message = 'Hello World';
message

Here message is a string literal.

Escaping Characters in a String
Let’s say we need to use the following string – 'I'm at the store right now'. As you can see here we have a single quote in the string itself. This won’t work.
To handle this we can use the \ symbol.
let message = 'I\'m at the store right now'
Using \’ solves the problem.

Joining two strings
To join or concatenate two strings we can use + operator.
let str1 = 'Hello';
let str2 = 'Sam';

str1+' '+str2

To convert a string to a number you can use the Number() function.
To convert a number to a string you can use toString()

Example
let numStr = '922';
typeof(numStr)

let num = Number(numStr);
typeof(num)

let tempStr = num.toString();
typeof(tempStr)

Template Literals or Template Strings
This is a new addition. Using this it’s convenient to concatenate strings or print out a variable value.
We use backtick instead of quotes.
let fName = 'Raj';
let message = Check this out. My name is ${fName};
message