Site within App

Asked

Viewed 2,268 times

6

I have a classified site, I need to create an Android app from my site, I do not program in Java, You can create an app where within it is displayed the site in mobile?

Type an iframe of the site within the app.

  • 2

    Search for phonegap/Ordova or Ionic; I think it’s the easiest way to do what you need.

3 answers

7


One option is to use the component Webview android. This component serves as a view that displays HTML files. Summarizing, it "puts" your website inside an application (.apk), and when running the application, it opens your website.

As an example, I’ll assume you already know some android IDE and the basics. You first modify your Layout file, getting like this:

<?xml version="1.0" encoding="utf-8"?>  
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"  
    android:id="@+id/webview"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"  
/> 

And in his Activity you call your Webview in the method Oncreate you call your website.

public void onCreate(Bundle savedInstanceState) {  
   super.onCreate(savedInstanceState);  
   setContentView(R.layout.main);  
   WebView myWebView = (WebView) findViewById(R.id.webview);  
   myWebView.loadUrl("http://www.example.com");  
} 

And in your Manifest file, you add permission to use the internet on your device, so:

<manifest ... >
    <uses-permission android:name="android.permission.INTERNET" />
    ...
</manifest>

It supports different screens, you can look more at this link.

Remembering that if you need something else, you can use the Phonegap, the Cordova or the Xamarin to develop something better. On them you find a lot of material in Google.

2

If you simply want to show the site "inside the app", just put a webview component in the app with the address of your site it will show the site in this view.

Webview - Class Overview

A View to show web pages. This class is the basis on which you can make your own web browser or simply display online content within your Activity. Uses the Webkit rendering engine to display web pages and includes methods to navigate back and forth through history, zoom in and out, search text and more.

0

Create an Android project and paste the code below and change the following line webView.loadUrl("http://www.google.com"); with the address of your website.

package com.mkyong.android;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class WebViewActivity extends Activity {

    private WebView webView;

    public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.webview);

       webView = (WebView) findViewById(R.id.webView1);
       webView.getSettings().setJavaScriptEnabled(true);
       webView.loadUrl("http://www.google.com");


    }

}

For more details and understand how it works or customize, read more on this site: Examples Webview Android

Browser other questions tagged

You are not signed in. Login or sign up in order to post.