Você está na página 1de 10

3/9/2019 How to Convert a Website into Android Application using Android Studio

CODEBIND.COM
FREE PROGRAMMING TUTORIALS AND LESSONS BY PROGRAMMINGKNOWLEDGE

HOME C C++ JAVA ANDROID LINUX SQLITE CODE PLAYGROUND

ABOUT

How to Convert a Website


FOLLOW US

into Android Application


using Android Studio
 December 17, 2016  admin  Android  37

Programmingknowl
7,682 likes

Epson Lig
Like Page

Discover Brand
ProgrammingKnowledge
Of Engaging Yo
Customers Wit YouTube 902R

Experiences.
www.epson.co.id

156

In this tutorial we will learn How to Convert a Website into Android


Application using Android Studio

So lets create a project.

Step 1 – Create new Android project.

Provide Activity name as EasyOnlineConverter

Step 2 – Add an webView to your activity as shown in the picture


below.

http://www.codebind.com/android-tutorials-and-examples/convert-website-android-application-using-android-studio/ 1/10
3/9/2019 How to Convert a Website into Android Application using Android Studio

layout/activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/r
    xmlns:tools="http://schemas.android.com/tools" android:layo
    android:layout_height="match_parent"
    tools:context=".MainActivity">
 
    <WebView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/webView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />
</RelativeLayout>

src/main/AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/and USEFUL TOOLS FOR
    package
package="com.example.programmingknowledge.easyonlineconvert
PROGRAMMERS
    <uses-permission android:name="android.permission.INTERNET"
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher" VideoToGifs.com
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
EasyOnlineConver
            android:name=".MainActivity"
            android:label="@string/app_name" >
ter.com
            <intent-filter>
                <action android:name="android.intent.action.MAI
SqliteTutorials.co
 
                <category android:name="android.intent.category
m
            </intent-filter>
        </activity>
    </application>
 
</manifest>

MainActivity.java

package com.example.programmingknowledge.easyonlineconverter;
 
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
 
 
public class MainActivity extends ActionBarActivity {
    private WebView myWebView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super
super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
http://www.codebind.com/android-tutorials-and-examples/convert-website-android-application-using-android-studio/ 2/10
3/9/2019 How to Convert a Website into Android Application using Android Studio

        myWebView = (WebView)findViewById(R.id.webView);
        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true
true);
        myWebView.loadUrl("http://www.easyonlineconverter.com")
        myWebView.setWebViewClient(new
new WebViewClient());
    }
 
    @Override Take your
    public void onBackPressed() {
        if
if(myWebView.canGoBack()) {
app ad
            myWebView.goBack();
        } else {
revenue
            super
super.onBackPressed(); to the
        }
    } next level.
 
    @Override
    public boolean onCreateOptionsMenu(Menu menu) { Sta now
        // Inflate the menu; this adds items to the action bar
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return
return true
true;
    }
 
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar w
        // automatically handle clicks on the Home/Up button, s
        // as you specify a parent activity in AndroidManifest
        int
int id = item.getItemId();
 
        //noinspection SimplifiableIfStatement
        if
if (id == R.id.action_settings) {
            return
return true
true;
        }
 
        return
return super
super.onOptionsItemSelected(item);
    }
}

menu/menu_main.xml

<menu 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" tools:contex
    <item android:id="@+id/action_settings" android:title="@str
        android:orderInCategory="100" app:showAsAction="never"
</menu>

OUTPUT

Now run your android app, and you will see the following result

Click the button below to Download Source code

Download Source Code

http://www.codebind.com/android-tutorials-and-examples/convert-website-android-application-using-android-studio/ 3/10
3/9/2019 How to Convert a Website into Android Application using Android Studio

Video Instructions

NEWSLETTER
How to Convert a Website into Android Applic…
Applic…
Subscribe to our newsletter and
stay updated on the latest
developments and special
o ers!

Name

Email *

Subscribe

 Post Views: 110,823


 ANDROID
SEARCH …

RECENT POSTS

SQLite vs MySQL: 16 Must-Know


Di erences Between The Two
Android Studio - Android Tutorial - Android Archiv Leading Databases
Android WebView Android UI Overview Page 3 of 3
Example How to Install VirtualBox Guest
Additions on Debian 9 Virtual
Machine (VM)

Scala – Reduce, fold or scan


(Left/Right)

How to install Maven on Mac OS

Pin Diagram and Pin Android Examples Android Studio How to install Jenkins on Ubuntu
description of 8085 Android SeekB 18.04 (Debian Linux)
Microprocessor Example

CATEGORIES

Partner Sites Select Category

VideoToGifs.com
RECENT COMMENTS
EasyOnlineConverter.com
SqliteTutorials.com Boss COTIGA on How to Install
PostgreSQL 9.6 on Ubuntu 18.04
ProgrammingKnowledge
LTS (Linux)
YouTube 902R
Aya Sato on Android MySQL
Database Tutorial – Android

PREVIOUS ARTICLE NEXT ARTICLE Login with PHP MySQL

Jeremy Holguin on How to Install


OpenCV in Ubuntu 16.04 LTS for
Python

Major Kiema mbandi (kiemanovic


on Android SQLite Database
http://www.codebind.com/android-tutorials-and-examples/convert-website-android-application-using-android-studio/ 4/10
3/9/2019 How to Convert a Website into Android Application using Android Studio

Sponsored Links Tutorial (Select, Insert, Update,


Delete)
The Most Beautiful Royal Women
Hooch disqus_kf0NYP9mhq on How to
Install OpenCV in Ubuntu 18.04
LTS for C / C++ (Linux)
Drone Ini Merupakan Penemuan Paling Luar Biasa Tahun 2018
DroneX Pro
ARCHIVES

The 10 Most Expensive Luxury Yachts in the World March 2019


easyvoyage
August 2018

June 2018
Best Flight Deals For Indonesia Departures May 2018
Flight Shop
April 2018

March 2018
This Is Why You Should Sleep on Your Left Side (Backed by
Science) February 2018
Health & Human Research
January 2018

11 Most Isolated Places At The End Of The Earth December 2017


Relocation Target
November 2017

October 2017

September 2017
Comments Community 
1 Login July 2017

 Recommend 3 t Tweet f Share Sort by Best May 2017

April 2017
Join the discussion…
March 2017
LOG IN WITH February 2017
OR SIGN UP WITH DISQUS ?

Name January 2017

December 2016

Mansoor Khan • a year ago November 2016


and how to add admob adds code like banner ad video
October 2016
adds etc please help us
60 △ ▽ • Reply • Share › September 2016

Aleksandar Stankovic • 2 years ago


August 2016

July 2016

June 2016

⛺ May 2016

META

7△ ▽ • Reply • Share › Register

Log in
Aniruddha Basak • 2 years ago
I can't able to download pdf files on this webview app. pls Entries RSS
help
Comments RSS
1△ ▽ • Reply • Share ›
http://www.codebind.com/android-tutorials-and-examples/convert-website-android-application-using-android-studio/ 5/10
3/9/2019 How to Convert a Website into Android Application using Android Studio

Rahul Gupta > Aniruddha Basak • a year ago WordPress.org

same problem with me please help..


△ ▽ • Reply • Share ›

Comments continue after advertisement


Sponsored

The Most Beautiful Royal Women


Hooch

Obeda Ale • 2 years ago


Good job but if it has any viedo in website it is not working
why
thanks
1△ ▽ • Reply • Share ›

Krlis Krkli • 2 years ago


is wrond. i put you code. for the test
i just copy and past you code but is don'

t workin'
2△ ▽ • Reply • Share ›

alexadu > Krlis Krkli • 2 years ago


How did you resolve that error code?
△ ▽ • Reply • Share ›

Christopher • 3 months ago


Pretty sweet quick and easy guide! I've got a similar
(slightly more in-depth) guide on converting your website
into an app here https://christopherwd.com/h... - even
includes setting up push notifications!
Cheers
△ ▽ • Reply • Share ›

Raza Rajwani • 5 months ago


Great Article, can you please share the steps for IOS apk
also
△ ▽ • Reply • Share ›

Richard S. Hartmetz • 5 months ago


The version of Android Studio I downloaded appears to be
an updated one, and a number of things are different.
When I attempted to paste the code in the appropriate
sections, it does not run the app, and gives errors at
http://www.codebind.com/android-tutorials-and-examples/convert-website-android-application-using-android-studio/ 6/10
3/9/2019 How to Convert a Website into Android Application using Android Studio
sections, it does not run the app, and gives errors at
different points. Is there an updated version of the
instructions?
△ ▽ • Reply • Share ›

Ome Chukwuemeka • 9 months ago


Is it possible to update the android app. if it is possible,
how can it be done since it was a website that was
converted into an apk file. thanks
△ ▽ • Reply • Share ›

Comments continue after advertisement


Sponsored

The Most Beautiful Royal Women


Hooch

rkhanda • 10 months ago


i just created an app as told to convert web to app. and
created my first ever APK file and run in my phone.
Only problem till now I found out that is when i click
shopping cart in Website it says "the item being added to
your shopping cart. However, in the app it does not show
that popup though it adds the item in my shopping cart.
What should i do? What changes I need to make in my
App.
Also I would like to change the APP Icon that is should
show the Icon I want for my APP in the mobile. What do i
need to do to change that icon?
△ ▽ • Reply • Share ›

Hussein Alhussein • a year ago


i did like you wrote but errors appear!!! any body help?
△ ▽ • Reply • Share ›

Bindeshwar Kush • a year ago


Very good tutorial, thanks for sharing,
△ ▽ • Reply • Share ›

Bounethone Sanasinh • a year ago


Very good and thank for sharing
△ ▽ • Reply • Share ›

‫ • תומר אברהם‬a year ago


hi thank you for your guide it was really helpful.
I have a question and I be glade if you can help me.
I convert a website that have a login screen how can I auto
fill this fields and submit ?
△ ▽ • Reply • Share ›

Mani Gopal • a year ago


many issues mostly appcompact library issue. Could you
start wiith install, SDK to be installed & library
dependencies ????
http://www.codebind.com/android-tutorials-and-examples/convert-website-android-application-using-android-studio/ 7/10
3/9/2019 How to Convert a Website into Android Application using Android Studio
dependencies ????
△ ▽ • Reply • Share ›

Comments continue after advertisement


Sponsored

The Most Beautiful Royal Women


Hooch

shilpa • 2 years ago


how to use call service when we convert website to mobile
app
△ ▽ • Reply • Share ›

jane • 2 years ago


okay baby
△ ▽ • Reply • Share ›

Willem Dodds > jane • 6 months ago


hahaha
△ ▽ • Reply • Share ›

Pankaj Pednekar • 2 years ago


how to copy and paste this code in android studio
△ ▽ • Reply • Share ›

Bharath Gajula • 2 years ago


Nice descriptive and very helpful.
△ ▽ • Reply • Share ›

Sagar Parmar • 2 years ago


Thank You.....very helpful
△ ▽ • Reply • Share ›

AJITH • 2 years ago


Thank you. It was very helpful. how can we view In
Desktop view from the android app.. now it is automatically
changed to mobile version when we access the URL from
app
△ ▽ • Reply • Share ›

Comments continue after advertisement


Sponsored

The Most Beautiful Royal Women


Hooch

Obeda Ale • 2 years ago


http://www.codebind.com/android-tutorials-and-examples/convert-website-android-application-using-android-studio/ 8/10
3/9/2019 How to Convert a Website into Android Application using Android Studio
Obeda Ale • 2 years ago
Good job but if it has any viedo in website it is not working
why
thanks <>
△ ▽ • Reply • Share ›

2018 september calendar > Obeda Ale


• 7 months ago
import android.view.MenuItem;
1△ ▽ • Reply • Share ›

Mohammed Khan • a year ago

△ ▽ • Reply • Share ›

Willem Dodds > Mohammed Khan • 6 months ago


Mohammed did you solve the problem it should say
myWebView, the name he gave at the top. I also
have/had this problem.
△ ▽ • Reply • Share ›

Visha sharma • a year ago


Error:Failed to capture snapshot of output files for task
'transformClassesWithDexForDebug' property
'streamOutputFolder' during up-to-date check.
> Failed to create MD5 hash for file
'C:\Users\Admin\AndroidStudioProjects\EasyOnlineConvert

What type of this issue? How to resolve?


△ ▽ • Reply • Share ›

Knoss • 2 years ago


the line... myWebView =
(WebView)findViewById(R.id.webView);

webView is an error
△ ▽ • Reply • Share ›

meet pal > Knoss • 2 years ago


replace with this
myWebView =
(WebView)findViewById(R.id.activity_main_webview
△ ▽ • Reply • Share ›

Shahzad Khursheed > meet pal


• a year ago
I replace with this line but still getting error
How to resolve it?
△ ▽ • Reply • Share ›

http://www.codebind.com/android-tutorials-and-examples/convert-website-android-application-using-android-studio/ 9/10
3/9/2019 How to Convert a Website into Android Application using Android Studio

alexadu > Knoss • 2 years ago


How did you resolve that error message?
△ ▽ • Reply • Share ›

Knoss > alexadu • 2 years ago


Like a silly Noob I am, I forgot to input the
below line in the activity_main.xml

android:id="@+id/webView" *aka I didn't


name Webview
△ ▽ • Reply • Share ›
Sponsored Links

The Most Beautiful Royal Women


Hooch

Drone Ini Merupakan Penemuan Paling Luar Biasa Tahun


2018
DroneX Pro

The 10 Most Expensive Luxury Yachts in the World


easyvoyage

Running A Wholesale Cloud Hosting Business


Superb Cloud

Best Flight Deals For Indonesia Departures


Flight Shop

This Is Why You Should Sleep on Your Left Side (Backed by


Science)
Health & Human Research

Like Share 7.6K people PARTNER SITES WEB HOSTING DONATE TO


Follow SERVICES PROGRAMMINGKNOW
@ProgrammingKnow LEDGE
VideoToGifs.com
EasyOnlineConverter.com Bluehost Web Hosting -
SqliteTutorials.com Starting at $3.45/month
1&1 Web Hosting -
Website Builder & Hosting
156

Copyright © 2019 | WordPress Theme by MH Themes

http://www.codebind.com/android-tutorials-and-examples/convert-website-android-application-using-android-studio/ 10/10

Você também pode gostar