Site within App

5

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

Type a site iframe within the app.

    
asked by anonymous 06.10.2015 / 02:52

3 answers

5

One option is to use the WebView component of Android. This component serves as a view that displays HTML files. In short, it "places" your site within an (.apk) application, and when you run the application, it opens your site.

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

<?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 your Activity you call your WebView in the OreCreate you call your site.

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 the device, thus:

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

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

Remembering that if you need anything else, you can use the PhoneGap , Cordova or the Xamarin to develop something better. You can find a lot of stuff on Google.

    
06.10.2015 / 13:47
1

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 that it will show the site in that view.

  

WebView - Class Overview

     

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

    
06.10.2015 / 03:24
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 site.

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 to understand how it works or customize, read more on this site: Android WebView Examples

    
06.10.2015 / 13:39