1. Download our Official Android App: Forums for Android!

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

Discussion in 'Android Development' started by jfrankparnell, Mar 8, 2016.

  1. jfrankparnell

    jfrankparnell Lurker
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    6
    Joined:
    Mar 8, 2016

    Mar 8, 2016
    6
    0
    15
    Male
    Anacortes, WA 98221
    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?
     

    Advertisement

  2. LV426

    LV426 I say we take off and nuke this place from orbit
    Recognized Developer
    Rank:
     #12
    Points:
    1,988
    Posts:
    9,176
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    9,176
    13,681
    1,988
    Male
    Software developer
    South West of England
  3. jfrankparnell

    jfrankparnell Lurker
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    6
    Joined:
    Mar 8, 2016

    Mar 8, 2016
    6
    0
    15
    Male
    Anacortes, WA 98221
    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.
     
  4. LV426

    LV426 I say we take off and nuke this place from orbit
    Recognized Developer
    Rank:
     #12
    Points:
    1,988
    Posts:
    9,176
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    9,176
    13,681
    1,988
    Male
    Software developer
    South West of England
    I don't know much about it. On first glance it looked like a way to turn an existing website into an Android app.
     
  5. HeavensSentSword

    HeavensSentSword Well-Known Member
    Rank:
    None
    Points:
    93
    Posts:
    134
    Joined:
    Jan 19, 2016

    Jan 19, 2016
    134
    36
    93
    Male
    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
    Code (Java):
    1.  
    2. import android.os.Bundle;
    3. import android.support.v7.app.AppCompatActivity;
    4. import android.view.KeyEvent;
    5. import android.webkit.WebSettings;
    6. import android.webkit.WebView;
    7. import android.webkit.WebViewClient;
    8.  
    9.  
    10. /**
    11. * Created by MMILLAR on 1/28/2016.
    12. */
    13. public class MyWebViewMain extends AppCompatActivity {
    14.     WebView myWebView;
    15.     String myUrl = "http://www.amazon.com";
    16.  
    17.  
    18.     @Override
    19.     protected void onCreate(Bundle savedInstanceState) {
    20.         super.onCreate(savedInstanceState);
    21.         setContentView(R.layout.webview_layout);
    22.  
    23.         myWebView = (WebView) findViewById(R.id.webview);
    24.         myWebView.setWebViewClient(new WebViewClient());
    25.         myWebView.loadUrl(myUrl);
    26.         WebSettings webSettings = myWebView.getSettings();
    27.         webSettings.setJavaScriptEnabled(true);
    28.  
    29.     }
    30.  
    31.     //allows users to navigate with the systems back button
    32.     @Override
    33.     public boolean onKeyDown(int keyCode, KeyEvent event) {
    34.         // Check if the key event was the Back button and if there's history
    35.         if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack()) {
    36.             myWebView.goBack();
    37.             return true;
    38.         }
    39.         // If it wasn't the Back key or there's no web page history, bubble up to the default
    40.         // system behavior (probably exit the activity)
    41.         return super.onKeyDown(keyCode, event);
    42.     }
    43. }
    44.  

    And this is the layout that you use with it.
    HTML:
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    3.    android:orientation="vertical"
    4.    android:layout_width="match_parent"
    5.    android:layout_height="match_parent">
    6.  
    7.     <WebView
    8.        android:id="@+id/webview"
    9.        android:layout_width="match_parent"
    10.        android:layout_height="match_parent"
    11.        android:background="#000000"
    12.        />
    13.  
    14. </RelativeLayout>
    Hopes this helps
     
  6. jfrankparnell

    jfrankparnell Lurker
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    6
    Joined:
    Mar 8, 2016

    Mar 8, 2016
    6
    0
    15
    Male
    Anacortes, WA 98221
    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/ .
     
  7. HeavensSentSword

    HeavensSentSword Well-Known Member
    Rank:
    None
    Points:
    93
    Posts:
    134
    Joined:
    Jan 19, 2016

    Jan 19, 2016
    134
    36
    93
    Male
    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.
     
  8. LV426

    LV426 I say we take off and nuke this place from orbit
    Recognized Developer
    Rank:
     #12
    Points:
    1,988
    Posts:
    9,176
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    9,176
    13,681
    1,988
    Male
    Software developer
    South West of England
    Building the APK is dead simple. Here's a video tutorial

     
  9. jfrankparnell

    jfrankparnell Lurker
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    6
    Joined:
    Mar 8, 2016

    Mar 8, 2016
    6
    0
    15
    Male
    Anacortes, WA 98221
    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.
     
  10. LV426

    LV426 I say we take off and nuke this place from orbit
    Recognized Developer
    Rank:
     #12
    Points:
    1,988
    Posts:
    9,176
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    9,176
    13,681
    1,988
    Male
    Software developer
    South West of England
    Did you add the android namespace binding to the manifest XML?
    This is how the start of the manifest should look..

    Code (Text):
    1.  
    2. <?xml version="1.0" encoding="utf-8"?>
    3. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    4. ...
    5.  
     
  11. jfrankparnell

    jfrankparnell Lurker
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    6
    Joined:
    Mar 8, 2016

    Mar 8, 2016
    6
    0
    15
    Male
    Anacortes, WA 98221
    Looks correct.
    Code (Text):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.carrezzy.www.cr02" >
    3.     <uses-permission android:name="android.permission.INTERNET" />
    4.     <application
    5.         android:allowBackup="true"
    6.         android:icon="@mipmap/ic_launcher"
    7.         android:label="@string/app_name"
    8.         android:theme="@style/AppTheme" >
    9.         <activity
    10.             android:name=".MainActivity"
    11.             android:label="@string/app_name" >
    12.             <intent-filter>
    13.                 <action android:name="android.intent.action.MAIN" />
    14.  
    15.                 <category android:name="android.intent.category.LAUNCHER" />
    16.             </intent-filter>
    17.         </activity>
    18.     </application>
    19.  
    20. </manifest>
     
  12. jfrankparnell

    jfrankparnell Lurker
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    6
    Joined:
    Mar 8, 2016

    Mar 8, 2016
    6
    0
    15
    Male
    Anacortes, WA 98221
    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.
     

Share This Page

Loading...