Android Development – Android Development Tutorial http://www.android-development-tutorial.net Hub of Android Development Sun, 20 Mar 2016 07:55:50 +0000 en-US hourly 1 https://wordpress.org/?v=4.5.3 Adding Interstitial Ad in Android Application – Video Tutorial http://www.android-development-tutorial.net/adding-interstitial-ad-in-android-application-video-tutorial/ http://www.android-development-tutorial.net/adding-interstitial-ad-in-android-application-video-tutorial/#respond Sat, 19 Mar 2016 10:50:07 +0000 http://www.android-development-tutorial.net/?p=3265 Interstitial Ads are full screen ads that cover whole interface of that their hosts app. To increase revenue from your android app, adding interstitial ad is the best option from admob network. As previously, we discussed about integrating admob ad banner in android app, similarly today we will integrate Interstitial ad in android application.

interstitial ad sample

In this tutorial, we will simply create a project where only one single button will be added. When the user hit button, it will show full ad screen which is Interstitial ad. So here we will integrate it as example and thus you can get clear ideas to add in your real android application.

Interstitial Ad Video Tutorial Here

Lets Get Started

  • Create a Project
  • Download Google Play Services Library
  • Copy & Paste a Project

Create a Project

First of all we should create a new project for this purpose. Keep in mind that all project name should exactly accurate and same as mentioned below.

  • Application Name : Interstitial Ad
  • Activity Name : MainActivity
  • Layout Name : activity_main
  • Package Name : net.android_development_tutorial.interstitialad

And then simply hit the Finish button to build your project.

Download Google Play Services Library

It is important to download latest Google Play Services Library from SDK Manager. There are two ways to find SDK Manager. The first one is SDK Manager icon in the toolbar as you can see in screenshot below.

sdk manager icon

 The second one is when you navigate to Tools > Android > SDK Manager. Now find the Google Play Services in Extras tab and install them if you haven’t  already.

google play services

Copy & Paste the Project

We will add some coding here to construct interstitial ad in MainActivity.Java | Copy and Paste the following coding in your project.

Please Note : You will need to get Admob publisher Ad Unit Id from your own account. The listed below one is default one from admob.

package net.android_development_tutorial.interstitialad;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;

import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;

public class MainActivity extends AppCompatActivity {
    InterstitialAd mInterstitialAd;
    Button mNewGameButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        mNewGameButton = (Button) findViewById(R.id.new_game);

        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");

        mInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdClosed() {
                requestNewInterstitial();

            }
        });

        requestNewInterstitial();

        mNewGameButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mInterstitialAd.isLoaded()) {
                    mInterstitialAd.show();
                }
            }
        });

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    private void requestNewInterstitial() {
        AdRequest adRequest = new AdRequest.Builder()
                .build();

        mInterstitialAd.loadAd(adRequest);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

Now Lets add button in activity_main.xml when user click on it, it show interstitial ad.

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="net.android_development_tutorial.interstitialad.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />



    </android.support.design.widget.AppBarLayout>

    <Button
        android:layout_marginBottom="55dp"
        android:id="@+id/new_game"
        android:text="Click Here"
        android:layout_marginTop="250dp"
        android:layout_marginLeft="150dp"
        android:layout_width="wrap_content"
        android:layout_height="90dp" />


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>

In build.gradle, add dependencies of Goolge Play Services.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "net.android_development_tutorial.interstitialad"
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
    compile 'com.google.android.gms:play-services:8.4.0'
}
Now Finally modify AndroidManifest.xml with internet permission and include the Adactivity configuration changes.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="net.android_development_tutorial.interstitialad">

    <!-- Include required permissions for Google Mobile Ads to run-->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!--Include the AdActivity configChanges and theme. -->
        <activity android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    </application>

</manifest>

Run The App

Now Its time to run the project to see whether it show interstitial ad when a button get clicked. Of-course it does, the interstitial ad will look like as below snapshot.

interstitial ad sample

 If you still have some question or have issue while creating project, please let us know we will get to you asap. Thanks

]]>
http://www.android-development-tutorial.net/adding-interstitial-ad-in-android-application-video-tutorial/feed/ 0
Android Custom ListView Example with Images [Video Tutorial] http://www.android-development-tutorial.net/android-custom-listview-example-with-images/ http://www.android-development-tutorial.net/android-custom-listview-example-with-images/#respond Thu, 03 Dec 2015 16:13:14 +0000 http://www.android-development-tutorial.net/?p=3187 In this android development tutorial, we will learn how to create awesome ListView for android app along with images (thumbnail). I think more than 90% android apps are consist of listview I have seen so far. I have been searching for a while to learn how to create custom listview or was trying to get some ready made code from somewhere for this purpose. Fortunately I got many beautiful listview example after searching and spending to many times on internet. If you are reading this tutorial, you are on right way just follow the below steps and get the code to create one of amazing listview.

android custom listview

Create New Project

  • You will need to create new project and Application Name should be ‘ListView’.
  • Activity to Mobile should be selected as ‘Blank Activity’.
  • Leave the Activity Name by default as ‘MianActivity’.
  • And rest of the things or configuration up to you whether you want to change it or not. (Will suggest you to leave it by default)
  • Once you done all things, hit Finish button to create project.

Related : How to Create Your First Android App – Hello World App

Implement Android ListView with Images

Ok so you have created the project with name of ‘ListView’. Now all you need is copy the code below and paste it on your project.

Create new Java Class with name of ‘CustomListAdapter.java’ and copy the code below & paste it over there.

CustomListAdapter.java

package net.android_development_tutorial.listview;

/**
 * Created by Saeed on 12/3/2015.
 */
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CustomListAdapter extends ArrayAdapter<String> {

    private final Activity context;
    private final String[] itemname;
    private final Integer[] imgid;

    public CustomListAdapter(MainActivity context, String[] itemname, Integer[] imgid) {
        super(context, R.layout.mylist, itemname);
        // TODO Auto-generated constructor stub

        this.context=context;
        this.itemname=itemname;
        this.imgid=imgid;
    }

    public View getView(int position,View view,ViewGroup parent) {
        LayoutInflater inflater=context.getLayoutInflater();
        View rowView=inflater.inflate(R.layout.mylist, null,true);

        TextView txtTitle = (TextView) rowView.findViewById(R.id.item);
        ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
        TextView extratxt = (TextView) rowView.findViewById(R.id.textView1);

        txtTitle.setText(itemname[position]);
        imageView.setImageResource(imgid[position]);
        extratxt.setText("Description "+itemname[position]);
        return rowView;

    };
}

 

Similarly, create Layout resource file with name of ‘mylist.xml’ & copy the code below & paste it over there.

mylist.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/icon"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:padding="5dp" />

    <LinearLayout android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:id="@+id/item"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="5dp"
            android:padding="2dp"
            android:textColor="#33CC33" />
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView"
            android:layout_marginLeft="10dp"/>
    </LinearLayout>
</LinearLayout>

 

In MainActivity.java, we have to give item name along with pictures. Make sure you have put pictures in your drawable folder otherwise it will give error. In short, copy the code below and paste it in your MainActivity.java

MainActivity.java

package net.android_development_tutorial.listview;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;


public class MainActivity extends AppCompatActivity {

    ListView list;
    String[] itemname ={
            "Car",
            "Camera",
            "Android",
            "Achievements",
            "Ball",
            "Barcode",
            "Basket",
            "Bike",
            "Book"

    };

    Integer[] imgid={
            R.drawable.ic_action_car,
            R.drawable.ic_action_camera,
            R.drawable.ic_action_android,
            R.drawable.ic_action_achievement,
            R.drawable.ic_action_ball,
            R.drawable.ic_action_barcode_2,
            R.drawable.ic_action_basket,
            R.drawable.ic_action_bike,
            R.drawable.ic_action_book,

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



        CustomListAdapter adapter=new CustomListAdapter(this, itemname, imgid);
        list=(ListView)findViewById(R.id.list);
        list.setAdapter((ListAdapter) adapter);

        list.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                                    int position, long id) {
                // When clicked, show a toast with the TextView text
                Toast.makeText(getApplicationContext(), "You clicked! Boom!!! =)",
                        Toast.LENGTH_LONG).show();

            }
        });
    }



    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

 

Finally we are adding ListView in our activity_main.xml. Just copy & paste following code in

activity_main.xml

<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="#f1ff00"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >
    </ListView>


</RelativeLayout>

Watch Video Tutorial Here

Run your Android App

Now we have successfully created android Custom ListView just one step away. Run your app and Insha-Allah you will get what you wanted. Our custom ListView should looks like

android custom listviewI hope you did found this tutorial helpful and please let me know if you have any trouble while developing custom  android ListView. I will get back to you as quickly as I can. Thanks & enjoy Custom ListView 🙂

]]>
http://www.android-development-tutorial.net/android-custom-listview-example-with-images/feed/ 0
Create Android App for Your Website/Blog [Video Tutorial] http://www.android-development-tutorial.net/create-android-app-for-your-websiteblog-using-webview/ http://www.android-development-tutorial.net/create-android-app-for-your-websiteblog-using-webview/#comments Sun, 29 Nov 2015 15:52:27 +0000 http://www.android-development-tutorial.net/?p=3177 Do you really want to have an android app for your website or blog? Of-course, as every single person want to become an android developer similarly every webmaster keen to have android app for their website to get more and more audience/traffics. Many companies, organization and small business owners’ even webmaster have already published their android app on Google Play Store. Now it’s your turn buddy 🙂

create android app for blog

There are some online tools to create android app but they will cost you for this. In this tutorial I’m going to show you how to create free android app using android studio for free. If you already know basic of Java and Xml language & basic usage of android studio then you are good to go. For beginners, have look at previous android development tutorials to get started even with no knowledge.

Create Android App for Website or Blog

Using android studio, we will manually create android application for website/blog using web view. Make sure that your site is Mobile Friendly otherwise it will create bad impression on user. Let get started,

Open your android studio and create new project with application name of your website or (could be anything) i.e. Android Development Tutorial.

Target the lowest android devices, select blank activity and leave Activity name as MainActivity by default & hit finish button to build your project.

These were basics things to create simple project now we will add important things to create android app for our blog or website.

First of all we will implement splash screen to our project as we have learned in last tutorial. To implement splash screen, check it out,

Read : Android Splash Screen Tutorial Using Android Studio

We will use WebView to show our website / blog contents in our android app online. In short, following are the coding of android app development for website using webview.

Watch Video Tutorial Here

Make sure to change website URL with your web URL in following line in MainActivity.java

mWebView.loadUrl("http://www.android-development-tutorial.net");

MainActivity.java

package com.topitideas.adt;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;


public class MainActivity extends Activity {

    private WebView mWebView;
    ProgressBar progressBar;


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

        mWebView = (WebView) findViewById(R.id.activity_main_webview);

        progressBar = (ProgressBar) findViewById(R.id.progressBar1);

        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        mWebView.loadUrl("http://www.android-development-tutorial.net");
        mWebView.setWebViewClient(new HelloWebViewClient());


    }

    private class HelloWebViewClient extends WebViewClient{


        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            // TODO Auto-generated method stub
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView webView, String url)
        {
            webView.loadUrl(url);
            return true;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            // TODO Auto-generated method stub
            super.onPageFinished(view, url);

            progressBar.setVisibility(view.GONE);
        }

    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)
    { //if back key is pressed
        if((keyCode == KeyEvent.KEYCODE_BACK)&& mWebView.canGoBack())
        {
            mWebView.goBack();
            return true;

        }

        return super.onKeyDown(keyCode, event);

    }




    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    public void onBackPressed() {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                MainActivity.this);

        // set title
        alertDialogBuilder.setTitle("Exit");

        // set dialog message
        alertDialogBuilder
                .setMessage("Do you really want to exit?")
                .setCancelable(false)
                .setPositiveButton("Yes",new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog,int id) {
                        // if this button is clicked, close
                        // current activity
                        MainActivity.this.finish();
                    }
                })
                .setNegativeButton("No",new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog,int id) {
                        // if this button is clicked, just close
                        // the dialog box and do nothing
                        dialog.cancel();
                    }
                });

        // create alert dialog
        AlertDialog alertDialog = alertDialogBuilder.create();

        // show it
        alertDialog.show();
    }
}

activity_main.xml

<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:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <ProgressBar
        android:layout_centerHorizontal="true"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_gravity="center_vertical|center_horizontal"
        android:id="@+id/progressBar1"/>

    <TextView
        android:layout_below="@+id/progressBar1"
        android:layout_height="wrap_content"
        android:id="@+id/LoadingText"
        android:layout_width="fill_parent"
        android:text="Loading, Please Wait.."
        android:textSize="20sp"
        android:gravity="center_horizontal">
    </TextView>

    <WebView
        android:id="@+id/activity_main_webview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</RelativeLayout>

SplashScreen.java

package com.topitideas.adt;

/**
 * Created by Saeed on 9/18/2015.
 */
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

/**
 * Created by vamsikrishna on 12-Feb-15.
 */
public class SplashScreen extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);

        Thread timerThread = new Thread(){
            public void run(){
                try{
                    sleep(3000);
                }catch(InterruptedException e){
                    e.printStackTrace();
                }finally{
                    Intent intent = new Intent(SplashScreen.this,MainActivity.class);
                    startActivity(intent);
                }
            }
        };
        timerThread.start();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        finish();
    }

}

splash.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:background="@drawable/splash"
    android:orientation="vertical">

</LinearLayout>

Now we will add piece of coding to AndroidManifest to get Internet Permission along with Splash Screen activity.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.topitideas.adt" >
    <uses-permission android:name="android.permission.INTERNET"/>

    <application

        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.topitideas.adt.SplashScreen"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.topitideas.adt.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.topitideas.tii.MAINACTIVITY" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>

</manifest>
 

Now Run Your Android App

You are almost done everything, now one thing you need to do before running your app is to put image in drawable folder for splash activity. Now run your android app either on emulator or real device to see whether its work properly or not. Your app will looks like,

android app for website

I hope it will works perfectly Insha-Allah & if you have any trouble or question, leave it in below comments to serve you better.  Enjoy Your Website Android App 🙂

]]>
http://www.android-development-tutorial.net/create-android-app-for-your-websiteblog-using-webview/feed/ 1
Working with Emulator and Real Devices – Android Development Tutorial http://www.android-development-tutorial.net/working-with-emulator-and-real-devices-android-studio-tutorial/ http://www.android-development-tutorial.net/working-with-emulator-and-real-devices-android-studio-tutorial/#comments Wed, 04 Nov 2015 16:41:54 +0000 http://www.topitideas.com/?p=3138 In this part of tutorial, Insha-Allah we will learn how to setup emulator and real devices with android studio. As we discussed in our last tutorial how to create hello world android app, but we didn’t learn how to run android app either on emulator or any real devices. This tutorial is also helpful for those who are unable to run their android apps on their system because Android Virtual Device Manager (AVD) takes too much space Ram memory and high processor requirements etc. If you have such a requirements that’s okay or if you don’t have such a requirements then you can still run your android app on external emulator and on real device.

Before publishing your app in Google Play Store, make sure to check your app on emulator and real device at least once time whether its work or show result as expected or not. Bur what if we don’t have access to any Android virtual emulator and real device? Now let’s go down to and clear the things up,

Android Virtual Device Manager (AVD Manager) – Official Emulator

During the installation of android studio, by default, emulator has been automatically created by android virtual device. You can access to Android Virtual Devices window by clicking on small phone icon at right upper side in toolbar. (See Screen shot)

AVD Manager

And you can also access AVD Manager by clicking on Tools > Android > AVD Manager.

android tools

In Android Virtual Device Manager window, you will see your virtual device something Nexus 5 API 23 which was created during installation by default. You can edit, wipe and delete it from list. Even you can create new Virtual Device using button below in this window.

Your virtual devices

Once you have done all the things according to your operating system, click on green run button right below action tab. Your emulator / virtual device will be launch and can takes long time to ON. Its takes about 5 to 10 minutes to show screen so you have to be patience.

In case of any error occurred, like “Cannot launch AVD in emulator” or “HAXM module is not installed” then you need to install HAXM installer package from Android SDK Manger. In order to find SDK Manager, click on Tools > Android > SDK Manager.

Working with Real Device

Once you have real android device then you can use it as a emulator. You can run/debug your app on real device easily without any trouble. I would prefer to use real device instead of AVD because it’s never slow down your system performance as official emulator do. Running your app is easy as 123. Let’s see how to setup real device with android studio,

  1. In Android SDK Manager, make sure you have install Google USB Driver package.google usb driver
  2. Make sure to enable USB debugging in your device. To find this option, go to Setting > General > Developer options and tick USB debugging option box.
  3. Now connect your real device with computer via original USB cable and simply run your android app.
  4. In pop up window, choose your real device and hit Ok. It may takes couple of minutes to install and launch app on your mobile.choosing real device

This is how you can use your real device just like emulator. If you have any question related to this then please use comment section below to help you better and better. Thank you for reading Stay Blessed.

]]>
http://www.android-development-tutorial.net/working-with-emulator-and-real-devices-android-studio-tutorial/feed/ 2
How to Create Your First Android App – Hello World App http://www.android-development-tutorial.net/how-to-create-your-first-android-app-hello-world-app/ http://www.android-development-tutorial.net/how-to-create-your-first-android-app-hello-world-app/#comments Tue, 27 Oct 2015 10:59:40 +0000 http://www.topitideas.com/?p=3102 New to android development? If yes then here you are on right place. We are going to discuss about creating first android application using android studio briefly. In last couple of posts, we did shared complete method to install android studio and JDK (Java Development Kit) on windows. After installing android studio and basics SDK packages on your system, the very next thing is comes how to create Hello World app. Now let’s get started.

first android app

What do you need?

Before creating an android app, you will need some of the basics knowledge about following languages,

  • Basic of XML
  • Basic of Java
  • Basic of Android Studio

If you have some knowledge about these programming languages then you are very very good to go. Unfortunately, if you are not familiar with these programming languages then don’t worry about it, you can still create your first android app just you need to follow our step by step guide.

Step by Step Guide To Create First Android App

Once you have successfully download and install android studio and their SDK bundle packages on your operating system, then you can easily proceed forward & develop your first android application by following steps below,

  1. Open the android studio and wait till Welcome to Android Studio Wizard ( It may takes several minutes to complete loading)
  2. Once it appears, Click on Start a new Android Studio Project right under Quick Start ( See Screenshot for help)welcome to android studio wizard
  3. In New Project Window, we have three important things here named Application name, Company domain and Project location
  • Application name : Obviously here we will type our application name which can be anything. (As we wrote name My First App in above snapshot)
  • Company domain : It will be your domain name as well as package name of your application. ( For example, we wrote it as COM)
  • Project location : A location where you project will be saved. For now Leave it as is default location is C:usersusernameAndroidStudioProjectsMyFirstApp
  1. Now after clicking next button, Target Android Devices window will be open. Here we have to choose minimum SDK or API for our app so let’s target Minimum SDK API 9: Android 2.3 (Gingerbread) and hit next button.
  2. In Add an activity to Mobile window, simply select the Blank Activity and hit next button. android blank activity
  3. In Customize the Activity window, the best way to customize your activity is to leave all four options as default. For example Activity Name : MainActivity, Layout Name: activity_main, Title: Main Activity, Menu Resource Name : menu_main. And then simply hit finish button and you’re done.customize the activity

Note : Your project will may takes several minutes to complete building files and other components. Once it done, you will have Mainactivity.java tab with Java codes and activity_main.xml tab with Xml codes. Following are the files looks like with coding,

MainActivity.java

package com.topitideas.myfirstapp;

    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;

    public class MainActivity extends AppCompatActivity {

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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
    return true;
    }

    return super.onOptionsItemSelected(item);
    }
    }

 

activity_main.xml

<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:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <TextView
    android:layout_centerInParent="true"
    android:textSize="50dp"
    android:textColor="#ff0000"
    android:text="@string/hello_world"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

    </RelativeLayout>

Watch Video Tutorial

Final Words

You have successfully created your first android app there is nothing else to do with coding just you need to run it on your real android device or on emulator. You application will look likefirst android app

Insha-Allah in our next tutorial we will be looking to work with emulator and real device means how to connect and run your application on emulator and on real device with android studio.

Let me know if you have any question or query related to this using comment and we love to reply your precious comments 🙂

]]>
http://www.android-development-tutorial.net/how-to-create-your-first-android-app-hello-world-app/feed/ 5
How to Install JDK (java Development Kit) on Windows http://www.android-development-tutorial.net/how-to-install-jdk-java-development-kit-on-windows/ http://www.android-development-tutorial.net/how-to-install-jdk-java-development-kit-on-windows/#comments Thu, 22 Oct 2015 17:24:33 +0000 http://www.topitideas.com/?p=3096 Previously, we have discussed about installing android studio and their basic environment setting and today we are going to learn how to install JDK (java Development Kit) on windows. JDK is used for writing Java codes & programs which comes in while developing android apps or using android studio and thus JDK is must while working with any Java related programs whether its android studio, eclipse and NetBeans etc. Many Java developers have already installed JDK on their system for developing java programs.

JDK is now named as Java SE which has come up with many version but here we need latest one for our system right now. The latest and standard edition is probably Java SE 8 / JDK 8. Here are some of simple easy steps to begin downloading and installing right one JDK for your computer system.

Downloading & Installing JDK 8

Following are the steps to install JDK on your windows OS all you need is,

  1. Click on Install Java SE 8 to visit official website of ORACLE.
  2. Find Java Platform (JDK) 8u65 / 8u66 and hit download button.jdk step by step download
  3. You will be redirecting to Java SE Development Kit downloads page. Here you will need to find the latest version called Java SE Development Kit 8u65. Tick on Accept License Agreement and choose the right product/File Description according to your windows operating system.
  4. Once you have find the accurate one, hit download link and your downloading will be starts.
  5. After you have successfully downloading file, install it on your system and enjoy.

That’s all done. You can now run and work with java programs comfortably. This latest version of JDK handle all kind of servers like JRE. You don’t need to download any other piece of programs for java programs anymore.

Once again JDK (Java Development Kit) is a software for java developers which is quite helpful in case of using android studio. Since android development required java coding for developing application, therefore JDK should must be installed on your operating system for that purpose.

Why to Install only Java SE or JDK?

Software Developers: JDK (Java SE Development Kit). For Java Developers. Includes a complete JRE plus tools for developing, debugging, and monitoring Java applications. (Source Oracle)

This is how to download and install JDK on your system windows. Let me know if something is missed or need some quick fix & help using comment section below.

Watch Video Tutorial Here

]]>
http://www.android-development-tutorial.net/how-to-install-jdk-java-development-kit-on-windows/feed/ 2