• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Need examples of webview based app, the site and the app

I've skimmed this http://developer.android.com/guide/webapps/webview.html I'm a php dev, so I think I get the picture: you can make an app out of your existing website, right? I want my website in the app stores, just as a marketing channel. My site is fully responsive, works great on phones. If I had an app which was simply a wrapper to a web browser, which had to stay in mydomain.com, that's all I need. I want people who are looking for an app to find it in the stores.

So, do I have the concept right? Can I have an app made which is just a view of my website? How much might some one charge for that? Is there a start to finish tutorial on making an app, specifically, this kind? Can you point to an example of a site and it's app?
 
That is 2 different things, right? Webview vs phonegap?
The phonegap wants you to upload html/css/js which I guess could work, if you did everything with ajax.
 
I don't know much about it. On first glance it looked like a way to turn an existing website into an Android app.
 
Here is a simple webview for you to use.
I built it and it runs fast and is easy to manipulate and change what you want. It only displays a webpage and it doesn't have anything fancy with it, but you can use it to nest in other app and make is sexy.

Here is the class you use for the webview
Java:
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;


/**
* Created by MMILLAR on 1/28/2016.
*/
public class MyWebViewMain extends AppCompatActivity {
    WebView myWebView;
    String myUrl = "http://www.amazon.com";


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

        myWebView = (WebView) findViewById(R.id.webview);
        myWebView.setWebViewClient(new WebViewClient());
        myWebView.loadUrl(myUrl);
        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);

    }

    //allows users to navigate with the systems back button
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // Check if the key event was the Back button and if there's history
        if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack()) {
            myWebView.goBack();
            return true;
        }
        // If it wasn't the Back key or there's no web page history, bubble up to the default
        // system behavior (probably exit the activity)
        return super.onKeyDown(keyCode, event);
    }
}


And this is the layout that you use with it.
HTML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#000000"
        />

</RelativeLayout>

Hopes this helps
 
That looks super helpful, thanks :) Is there a tut for how to put those two pieces into an apk? This looks like it would get me part way: https://developer.chrome.com/multidevice/webview/gettingstarted But, it never gets to the part where it says 'ok now just save your app as yourapp.apk!' I'm all for hiring someone to make this, for me. Which is why I was hoping to find some example pairs. I would put the project out for bid, using the examples as ...examples. Here is the site, if you're interested: http://www.carrezzy.com/ .
 
you can just use the above code and replace amazon.com with carrezzy.com and it would work . Unless you need to have a login or other things to keep user info in the phone it would be easy to change it.
I don't know anything about the apk I haven't got that far myself. But, I bet there is a option in android studio to deal with this and will automatically build it and run it.
 
Building the APK is dead simple. Here's a video tutorial

 
well, i got it almost going. it at least tried to display the site in the emulator. But, i assumed it needs permission to use internet, so i made a AndroidManifest.xml and added the permission (as given in many tuts) but got
Error:The prefix "android" for attribute "android:name" associated with an element type "uses-permission" is not bound. I searched on this error, quite thoroughly. Found nothing to fix it.
 
Did you add the android namespace binding to the manifest XML?
This is how the start of the manifest should look..

Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
 
Looks correct.
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.carrezzy.www.cr02" >
    <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=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>
 
I rebuilt from scratch and got it going! installed the apk on my phone and everything. Rad, thanks. How do i do a 'save as' for the app. Like, it took app01, app02, app03 to get it working...i want to save as app04, so as to not lose my work at app03.
 
Back
Top Bottom