Android Helps – 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.2 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/#respond 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/ 0
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