Creating a simple “Hello world” application on Android Studio

Android Studio is the  IDE (Integrated Development Environment) for android application development.We will be working on Android studio to make our first application “Hello world”.First, download the Linux SDK from the Android website.

Copy it to some location and unzip it to extract the contents.

sudo apt-get install unzip

sudo tar xvzf android-studio-ide-135.1641136-linux.zip

Open a terminal from the location

cd android-studio-ide-135.1641136-linux

Run the following command to load the android studio.

./studio.sh

Once Android Studio is launched , we need to mention JDK path in the installer.If JDK is not pre-installed,it is possible to install it from there.Go to next and specify the JDK path.After that select the components required to build the application which includes Android Studio,Android SDK,Android Virtual Machine and performance (Intel chip).In the next option,we need to give the path for Android studio and android SDK.Next,you will be asked to specify the RAM space for Android emulator.It is 512 MB by default.The final step is the extraction of SDK package into our machine.After its successful completion,click on finish button.

The Android Studio Setup Wizard appears.Select new application and name it.Then we need to give the minimum SDK requirements.In the next step,select a blank activity.This opens a development tool for our application.

Go to  App>res>layout>Activity_main.xml

In the design area, drag a text view widget and type “Hello world” in it.

We can test our application either by creating a virtual Android device or by connecting a phone to USB debugging(developer) mode.

Connect to the device.Run the application.You will see the “Hello world” message in it.

                                       studio17

YaaY!you have made your first android application.Play with Android studio and explore it to depth 🙂

.

 

Advertisements

Laravel

Recently I wrote an article on the framework Laravel.Let me wrap up the main contents of the article here.

What is Laravel ?

Laravel is one of the best open source PHP web framework.It is an elegant  and comfortable framework to work on.It has a very neat syntax and makes web development easier.The prerequisite to work on Laravel is the basic knowledge in PHP. It follows MVC (Model View Controller) Architecture.It was created by Taylor Otwell in 2011.

Key Features:

Laravel holds the following key features which make it a flexible framework.

Routing system-It automatically create links to the named routes and insert the correct URI. A directory(where all routes are specified) is created.If a file text.php is added.It can be accessed by browsing to ‘localhost/directory/text.php.

Unit testing-It runs many tests to ensure that new changes are updated correctly.It is easy to write unit-tests for the own code.

View composers-These are class methods that are called when a view is returned.

Bundles-It provides a modular packaging system with many features and add-ons to the application.

Composer-This is a dependency manager to add framework-agnostic and Laravel-specific PHP packages available from the Packagist repository.

Automatic pagination-Automatic pagination simplifies the task of implementing pagination, replacing the usual manual implementation approaches with automated methods.

Form request -It is a special class for validating and authorizing form submissions.

Database seeding -Updating database tables with selected default data.

Migrations-Adding the changes of the application’s codebase in the database layout.

Authentication-It contains the ready to use inbuilt authentication system. You just need to configure database migrations, models, controllers and views to make the system work.

Restful controllers – It allows you to create methods directly from your controller which gets automatically mapped to your routes.

Query builder- Laravel’s query builder provides a set of classes and methods capable of building queries programmatically.

Controller method injection-Dependencies can be injected directly to the methods.There is no need of constructors.This helps to write neat codes.

Eloquent ORM-This allows us to work with the database objects and relationships using an easily understandable syntax.

Inversion of control (IoC) principle-It is a Programming style where a framework controls the program flow.

Blade-Its a system for maintaining templates.

Command Line Interface (CLI)-Artisan is the CLI used in Laravel.It provides a number of helpful commands that can assist you while you build your application.

Installation and environment set up:

First set up the environment

$sudo apt-get update

$sudo apt-get upgrade

Install LAMP (Linux, Apache, MariaDB, PHP)  server.

$sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-mysql php5-gd

I would recommend you to use PHP 5.4 or above because of the older versions installation of dependencies with composer takes much time.

$sudo apt-get install python-software-properties

$sudo add-apt-repository ppa:ondrej/php5-oldstable

$sudo apt-get update

$sudo apt-cache policy php5

Install the necessary PHP along with the needed extensions.

 $sudo add-apt-repository ppa:ondrej/php5

 $sudo apt-get update

 $sudo apt-get install php5 php5-mcrypt php5-gd

 $sudo php5enmod mcrypt

Install composer

$ curl -sS https://getcomposer.org/installer | php

Then we need to move composer to the bin directory and enable permissions to the folder.

$ sudo mv composer.phar /usr/local/bin/composer

$ sudo chmod +x /usr/local/bin/composer

Clone the master repo of laravel from github.

$cd /var/www

$git clone https://github.com/laravel/laravel.git

We get into the code directory and install all dependencies needed with the help of composer.

$ cd /var/www/laravel

$ sudo composer install

Then give proper permission to files with chmod command as used before.

Create a new directory  for your new Laravel project. After that, move to the path where you have created the new directory and type the following command there to install Laravel.

$composer create-project laravel/laravel –-prefer-dist

Start Laravel service by the following command:

$php artisan serve

You will see a URL. Open that URL in the browser. To ensure that Laravel has been installed successfully .

webpage

 

Application Structure :

The root directory of Laravel:

app − This directory contains the core code of the application.

bootstrap − It contains the application bootstrapping code.

config − It contains configuration files of the application.

database − This folder contains  database migration.

public − This is the  root file of the application. It contains the assets of the application like JavaScript, CSS, Images, etc.

resources − It contains raw assets ,localization and language files, and templates .

storage − It has app storage,framework storage , and application-generated logs.

test − This directory contains various test cases.

vendor − It  contains composer dependencies.

App directory contains the following subdirectories :

Console − All the artisan commands are stored here.

Events − This directory stores events that your application can raise.

Exceptions − It has the application’s exception handler.

Http − It contains your controllers and requests.

Jobs − This directory contains the queueable processes for your application.

Model view controller flow :

Laravel follows the model-view-controller (MVC) architectural pattern.A browser sends a request, which is received by a web server.This request is given to the Laravel routing engine.Based on the routing pattern Laravel router sends it to the controller. Sometimes, the controller will immediately render a view, which is a template that gets converted to HTML and sent back to the browser. More commonly for dynamic sites, the controller interacts with a model and communicates with the database. After invoking the model, the controller then renders the final view (HTML, CSS, and images) and returns the complete web page to the user’s browser.

laravel_mvc

Advantages of the framework:

Laravel is an elegant framework with many assets. It has clean code and APIs.The code is easily maintainable by the developer.It has a strong version control system and user-friendly interface.The customized tools in Laravel help in the development of application easier without any complications.With an integrated unit testing support system, we can ensure the proper working of the application.It provides high performance and security.Laravel framework stays up to date with the technology.Many versions with more features have been developed to extend the whole framework .