Skip to main content

Website to Android App | Android Tutorials | Covert your website an Android App.




Ever Dream about an Android app. Let us Start with Simple Website 
to an Android app.All you need is Create a Project with Empty layout
in Android Studio, and replace with the below files, 
all you need to do is replace "Package Name","tool.context",
"webView.Url","appName" . Thats it. Your app is ready. If you need 
how to change your icon, Ask me in comment box.


Activity_main.xml


<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"android:layout_height="match_parent"
android:paddingBottom="5dp"android:paddingLeft=
"5dp"android:paddingRight="5dp"android:paddingTop="5dp"android:orientation=
"vertical"android:gravity="center_horizontal|center_vertical"    
tools:context="com.rgsupports.www.example.MainActivity">

<WebView    android:id="@+id/webView"    android:layout_width="fill_parent"    
android:layout_height="fill_parent" />

<LinearLayout    android:id="@+id/layoutProgress"   
 android:layout_width="fill_parent"    android:layout_height="fill_parent"    
android:orientation="vertical"    android:gravity=
"center_horizontal|center_vertical" >
    <TextView        android:id="@+id/textLoading"        
android:text="@string/label_loading"        android:textSize="20sp"  
      android:textStyle="bold"        android:layout_width="wrap_content"   
     android:layout_height="wrap_content" />
    <View        android:layout_width="fill_parent"       
 android:layout_height="20dp" />

    <ProgressBar        android:layout_width="fill_parent"   
     android:layout_height="26dp"        android:id="@+id/progressBar"    
    style="?android:attr/progressBarStyleLarge"      
  android:layout_gravity="center_vertical" />
</LinearLayout>

</FrameLayout>



Mainactivity.java



package com.rgsupports.www.example;

        import android.content.Context;
        import android.graphics.Bitmap;
        import android.net.ConnectivityManager;
        import android.net.NetworkInfo;
        import android.support.v7.app.AppCompatActivity;
        import android.os.Bundle;
        import android.view.View;
        import android.webkit.WebSettings;
        import android.webkit.WebView;
        import android.webkit.WebViewClient;
        import android.widget.LinearLayout;
        import android.widget.ProgressBar;
        import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    private WebView webView;
    private ProgressBar progressBar;
    private LinearLayout layoutProgress;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        webView = (WebView) findViewById(R.id.webView);
        progressBar = (ProgressBar) findViewById(R.id.progressBar);
        layoutProgress = (LinearLayout) findViewById(R.id.layoutProgress);
        webView.setVisibility(View.GONE);
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setBuiltInZoomControls(true);
        settings.setSupportZoom(true);
        settings.setDisplayZoomControls(false);
        webView.setWebViewClient(new WebViewClient() {
            @Override           
         public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }

            @Override           
         public void onPageFinished(WebView view, String url) {
                webView.setVisibility(View.VISIBLE);
                layoutProgress.setVisibility(View.GONE);
                progressBar.setIndeterminate(false);
                super.onPageFinished(view, url);

            }

            @Override           
          public void onPageStarted(WebView view, String url, Bitmap favicon) {
                layoutProgress.setVisibility(View.VISIBLE);
                progressBar.setIndeterminate(true);
                super.onPageStarted(view, url, favicon);
            }
        });
        if(isOnline()) {
            webView.loadUrl("https://www.example.com");
        } else {
            String summary = 
        "<html><body><font color='red'>No Internet Connection</font></body></html>";
            webView.loadData(summary, "text/html", null);
            toast("No Internet Connection.");
        }
    }
    private void toast(String message) {
        Toast.makeText(this, message, Toast.LENGTH_LONG).show();
    }

    private boolean isOnline() {
        ConnectivityManager cm =
 (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netInfo = cm.getActiveNetworkInfo();
        return (netInfo != null && netInfo.isConnected());
    }
}



String.xml


<resources>
    <string name="app_name">App Name</string>
    <string name="label_loading">Loading..</string>
</resources>



AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android=
"http://schemas.android.com/apk/res/android"package="com.rgsupports.www.example"
android:versionCode="1"android:versionName="1.0" >

<uses-sdk    android:minSdkVersion="8"    android:targetSdkVersion="23" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application    android:allowBackup="true"    
android:icon="@mipmap/ic_launcher"    android:label="@string/app_name" 
   android:supportsRtl="true"    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

</manifest>



Comments

Popular posts from this blog

Year in Review | Facebook New Year video | Facebook

FB New Year in Review How can I see, edit and share my Year in Review? Your Year in Review is a personalized video that lets you highlight and share your meaningful moments from this year. These moments can include photos and posts that you've shared or been tagged in. To see your Year in Review visit  facebook.com/yearinreview2016  or click  Watch Yours  on a Year in Review that has been shared by a friend. You may also see your Year in Review video in your News Feed, but it's only visible to you unless you share it. To share your Year in Review: Go to  facebook.com/yearinreview2016 Click  Share Video Select the audience  for the post Click  Post To edit your Year in Review before you share it: Go to  facebook.com/yearinreview2016 Click  Edit Video  and then choose the photos you want to appear in your video Click  Share Select the audience  for the post Click  Post You can als...

Getting Started with Kubernetes Engine | GCP

Getting Started with Kubernetes Objectives In this lab you create a Kubernetes Engine cluster containing several containers, each containing a web server. You place a l oad balancer in front of the cluster and view its contents. In this lab, you learn how to perform the following tasks: Provision a  Kubernetes  cluster using  Kubernetes Engine. Deploy and manage Docker containers using  kubectl .Sign in to the Google Cloud Platform (GCP) Console Make sure that you have access to a standard web browser. The Google Chrome browser is recommended Sign in to the Google Cloud Platform Console by using the username and password  Confirm that needed APIs are enabled Make a note of the name of your GCP project. This value is shown in the top bar of the Google Cloud Platform Console. It will be of the form  qwiklabs-gcp- followed by hexadecimal numbers. In the GCP Console, on the  Products & Services  ( ) menu, click...

Online Cricket Betting, Its Cricket Fever..!!!!! bet365.com

hi friends, cricket fever all over the world, and betting bookies rule the time, want to become imran hasmi in jannat.. lollll jus for fun, but for the information here are some best bookies in the online for betting. don't invest more its my suggestion dude.. never addict to easy money :) Bet365 bet365 customers can set up an online betting account from an Indian address. People setting up an account at bet365 can also choose to manage their account in Indian Rupees rather than in U.S Dollars or British Pounds. bet365 will accept bets from Indian customers in every state in India. bet365 is one of the world’s largest online bookmakers and is based in Stoke in the United Kingdom. It is a family-owned business belonging to the Coates family, who also own Stoke City football club. It is one of the most respected and trusted bookmaking businesses in the world. Customers in India can deposit money into their bet365 account using their debit card, credit card, NETELL...