Skip to main content

Begin to code the First android app - ABNHive

We discussed android a lot in previous articles. Now let's begin to code. Before that, we need to know about Android Studio.
Android Studio is the official Integrated Development Environment (IDE). Before reading this you should read this portion.

Begin to code the First android app - ABNHive

Why we need the Android studio

  • A flexible Gradle-based build system
  • A fast and feature-rich emulator
  • A unified environment where you can develop for all Android devices
  • Instant Run to push changes to your running app without building a new APK
  • Code templates and GitHub integration to help you build common app features and import sample code
  • Extensive testing tools and frameworks
  • Lint tools to catch the performance, usability, version compatibility, and other problems
  • C++ and NDK support
  • Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud Messaging and App Engine
Now Download Android Studio and other tools. I mentioned about tools in here.
Let's create a HelloWorld Application.

Create a New Project in Android Studio

  1. Open Android Studio 
  2. Click  'Start a new Project studio project'
  3. Enter project Details like 
    • Name - Name of the app and the first letter should be capital.  example: HelloWorld
    • Package - The name of Java Package, it is used to organize Java classes into namespaces example: com.helloworld.program
    • Project Location - Set location on your drive
  4. Click Next 
  5. Select Minimum SDK Version - Already selected option is 14, that version has all device support
  6. Click on Next
  7. Select An Activity like Blank Activity
  8. Next
  9. Finish
Then Android Studio loads its components.

This is the Main Activity of your app.

      

package com.example.helloworld;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
   }
}


       

Connect your mobile with PC. Open settings and enable USB Debugging.
Then click on this icon.

Begin to code the First android app - ABNHive

Now choose your device. 
After opening on mobile your activity will run like this. 
Begin to code the First android app - ABNHive

- Aswin Bhim Nath

Comments

Popular posts from this blog

Shortcuts in Android Studio for Android Developers - ABNHive

I hope these shortcuts will definitely help you to increase the productivity level. Search for command: cmd + shift + a ( Windows / Linux : ctrl +  shift + a) You just type: close and you’ll get a proper shortcut/command. Choose from the last copy / pastes : cmd +  shift  + v ( Windows / Linux : Ctrl + Shift + v). By default, there are 5 last copy/paste items. Enable mulmulti cursorature: ctrl + g (alt + j for Windows / Linux ). Open a class: cmd + o ( Windows / Linux : ctrl + n). Open any file: cmd + shift + o ( Windows / Linux : ctrl + shift + n) Open symbol:  cmd + option + o ( Windows / Linux : alt + shift + n). Go to implementation: cmd + option + b ( Windows / Linux : ctrl + alt + b). Go to declaration: cmd + b ( Windows / Linux : ctrl + b).  Go to type declaration: control + shift + b ( Windows / Linux : ctrl + shift + b).  Go to super: cmd + u ( Windows / Linux : ctrl + u).  Move between tabs: cmd + shift + [ (move left) or cmd + shift + ] (move right) ( W

Android Application Components Activities, Services, Broadcast Recievers, Content Providers - ABNHive

Application components are the essential building blocks of Android app development.  Each component is an entry point through which the system or a user can enter your app. There are 4 types of components in android Activities Services Broadcast receivers Content providers Let's dive into the deep.  Activities This is a component that represents a single screen with a user interface or simply an entry point for interacting with the user. Example, an email app might have one activity that shows a list of new emails. Activities work together to form a cohesive user experience in the app. For example, clicking a button on the first screen might replace that screen with another screen containing other widgets, a web page, a movie, or text information. Activities are typically created by subclassing (extending) the Android class Activity.  click here   to know more about Activity. Services This runs in the background to perform work for remote processes or

Linear Layout in Android - ABNHive

Linear Layout arranges other views either horizontally in a single column or vertically in a single row. It arranges its elements sequentially Attributes android: orientation —Used for arranging the controls in the container in horizontal or vertical order android:layout_width —Used for defining the width of a control android:layout_height —Used for defining the height of a control android:padding —Used for increasing the whitespace between the boundaries of the control and its actual content android:layout_weight —Used for shrinking or expanding the size of the control to consume the extra space relative to the other controls in the container android:gravity —Used for aligning content within a control android:layout_gravity —Used for aligning the control within the container Example <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_widt