Subversion Repositories HomeAutomation

Rev

Blame | Last modification | View Log | SVN | RSS feed

  1. package com.example.webgui;
  2.  
  3. import android.os.Bundle;
  4. import android.view.Window;
  5. import android.webkit.WebChromeClient;
  6. import android.webkit.WebView;
  7. import android.webkit.WebViewClient;
  8. import android.app.Activity;
  9. import android.view.Menu;
  10.  
  11. public class MainActivity extends Activity {
  12.  
  13.     WebView mWebView;
  14.    
  15.     @Override
  16.     protected void onCreate(Bundle savedInstanceState) {
  17.         final Activity mActivity = this;
  18.        
  19.         super.onCreate(savedInstanceState);
  20.        
  21.         // Adds Progress bar Support
  22.         this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
  23.        
  24.         setContentView(R.layout.activity_main);
  25.        
  26.         // Makes Progress bar Visible
  27.         getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
  28.  
  29.         mWebView = (WebView) findViewById( R.id.webview );
  30.         mWebView.getSettings().setJavaScriptEnabled(true);    
  31.         mWebView.loadUrl("http://<url to your webgui server here>");
  32.        
  33.         mWebView.setWebViewClient(new WebViewClient());
  34.         /*mWebView.setWebChromeClient(new WebChromeClient()
  35.         {
  36.             public void onProgressChanged(WebView view, int progress)  
  37.             {
  38.                 //Make the bar disappear after URL is loaded, and changes string to Loading...
  39.                 mActivity.setTitle("Loading...");
  40.                 mActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded
  41.  
  42.                 // Return the app name after finish loading
  43.                 if(progress == 100)
  44.                 {
  45.                     mActivity.setTitle(R.string.app_name);
  46.                 }
  47.             }
  48.         });*/
  49.     }
  50.  
  51.     @Override
  52.     public boolean onCreateOptionsMenu(Menu menu) {
  53.         // Inflate the menu; this adds items to the action bar if it is present.
  54.         getMenuInflater().inflate(R.menu.activity_main, menu);
  55.         return true;
  56.     }
  57.    
  58. }
  59.