Install Andoid Studio on Ubuntu

Introduction

To be successful, Android developers need a good grasp of the Java Language(or Kotlin), Andoid API’s, and Android application architecture. It’s also important to use an appropriate and effective development environment. For many years, Eclipse IDE with the ADT plugin was the preferred platform for Android development. Today, it’s Andoid Studio.

Android Studio is Google’s officially supported IDE for developing Android apps. This IDE is based on Intellij IDEA, which offers a powerful code editor and developer tools.

Installation

Setting up Android Studio takes just a few commands.

First command is to install Java through this command, if you already installed Java skip this step:

sudo add-apt-repository ppa:webupd8team/java

And then update command:

sudo apt update

And then installation command:

sudo apt-get install oracle-java8-installer

When installation start, the following dialog box popup on your screen for the configuration of Java:

jdk1.png

Read More »

Creating New Activity and Transferring Data

How to create new activities and transfer data from one activity to another activity?

Intro

So far we are working on a single screen on a single activity.
How we start one activity from another activity, instead of having activities directly call each other, android facilitates communication using message object called intent.Intents let an app request that an action take place, that will be any thing i.e start a new activity ,open a gallery or open a camera etc.Intents is like envalop, each one include who, component you want to deliver to.component recieve this and read it. And open the intent.

Working

First start a new project and open the activity_main.xml and make linear layout and inside linear layout make EditText and button and give them proper ID’s .And also set dimens.

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity">
    
    

Read More »

Guide to establish Android Network Connection

Most of the application in android now a days use data from internet it might be contacts, game data, weather or other information.This data is provided from internet through Web API’s.

In this tutorial we can take an example of Github Query App and make a connection of Android App to internet.

Creating Layout

After starting empty activity in a new project in Android Studio,First thing you have to do is  to open activity_main.xml and make some changes.Delete a Constraint Layout and create a new Linear Layout.Create a EditText, inside Linear Layout, where user can enter their input data and give proper ID to EditText and other properties.Create a TextView,inside Linear Layout, to show the Url and give proper ID and other properties.You have to create a ScrollView,inside Linear Layout, to scroll on a result. Create a TextView inside the ScrollView and give proper ID to this and other properties.

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="16dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="22sp"
        android:id="@+id/et_search_box"
        android:hint="Enter a query and click search" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="22sp"
        android:id="@+id/tv_url_display"
        android:layout_marginTop="8dp"
        android:hint="your search will be shown here"/>
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="18sp"
            android:id="@+id/tv_github_search_result_json"
            android:hint="make a search"/>
    </ScrollView>
</LinearLayout>

Now move to MainActivity.java and make some changes.Create a variable for EditText and TextView inside the MainActivity class.Read More »