Monday 22 May 2017

what is kotlin

Kotlin is a official programming language to develope android application. Google announce that in Google io 2017.
Kotlin is a programming language that rung on Java Virtual Machine. Kotlin is designed by JetBrains.

To see difference between java and kotlin click below link.
https://kotlinlang.org/docs/reference/comparison-to-java.html

Simple difference between java and kotlin language.



Before going to develop app using kotlin first you want to download Android Studio 3.0 Canary or you can also add Kotlin plugin to your existing Android studio.

To install kotlin plugin in your android studio follow below steps

Go to File => Settings.

From left side panel choose plugin => now select Install JetBrain Plugin => now search kotlin from search bar.

You see kotlin plugin listed in below window. Now in right side on window press Install button.

See following video to install kotlin plugin.



To download Android studio canary version click following link. https://developer.android.com/studio/preview/index.html

Saturday 20 May 2017

How to create Splash screen in android

Android splash screen are normally used to show user some kind of progress before the app loads completely or show company logo.



splash screen demo
Splash Screen



First create android project in Android studio and give activity name as Splash.

Now Paste following code in your activity_splash.xml file.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="@color/black"
    tools:context="com.app.splashscreen.SplashActivity">

    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerInParent="true"
        android:src="@drawable/ic_android"/>

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="38dp" />
    
</RelativeLayout>


Now Paste following code in your Splash.java file.


import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class SplashActivity extends AppCompatActivity {

    int SPLASH_TIME_OUT = 1500;

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        new Handler().postDelayed(new Runnable() {
            @Override            public void run() {
                startActivity(new Intent(getApplicationContext(),HomeActivity.class));
                finish();
            }
        },SPLASH_TIME_OUT);
    }
}

Create one another activity named HomeActivity to open after Splash scree.