SHARE
TWEET

Untitled

a guest Oct 24th, 2014 155 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     package com.codepunker; // replace this with your package name
  3.  
  4.     import android.os.Bundle;
  5.     import android.annotation.SuppressLint;
  6.     import android.app.Activity;
  7.     import android.content.Intent;
  8.     import android.view.KeyEvent;
  9.     import android.view.View;
  10.     import android.webkit.WebView;
  11.     import android.webkit.WebViewClient;
  12.     import com.codepunker.codePunkerWebViewC;
  13.     import android.net.Uri;
  14.     import android.graphics.Bitmap;
  15.     import android.widget.ProgressBar;
  16.  
  17.     public class Index extends Activity //rename Index with your activity name
  18.     {
  19.       private WebView codePunkerWebView;
  20.       private ProgressBar progressBar;
  21.  
  22.       @Override
  23.       public boolean onKeyDown(int keyCode, KeyEvent event)
  24.       {
  25.           if ((keyCode == KeyEvent.KEYCODE_BACK) && codePunkerWebView.canGoBack())
  26.           {
  27.           codePunkerWebView.goBack();
  28.             return true;
  29.           }
  30.           return super.onKeyDown(keyCode, event);
  31.       }
  32.  
  33.       @SuppressLint("SetJavaScriptEnabled") //remove the stupid warning
  34.       @Override
  35.       protected void onCreate(Bundle savedInstanceState)
  36.       {
  37.       super.onCreate(savedInstanceState);
  38.         setContentView(R.layout.activity_index);
  39.  
  40.         codePunkerWebView = (WebView) findViewById(R.id.webview);
  41.         progressBar = (ProgressBar) findViewById(R.id.progressBar1);
  42.  
  43.         WebViewClient client = new codePunkerWebViewC()
  44.         {
  45.             @Override
  46.             public void launchExternalBrowser(String url)
  47.             {
  48.               Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
  49.               startActivity(intent);
  50.             }
  51.          
  52.             @Override
  53.             public void onPageStarted(WebView codePunkerWebView, String url, Bitmap favicon)
  54.             {
  55.               super.onPageStarted(codePunkerWebView, url, favicon);
  56.             }
  57.  
  58.             @Override
  59.             public void onPageFinished(WebView codePunkerWebView, String url)
  60.             {
  61.               super.onPageFinished(codePunkerWebView, url);
  62.               progressBar.setVisibility(View.GONE);
  63.             }
  64.         };
  65.        
  66.         codePunkerWebView.setWebViewClient(client);
  67.         codePunkerWebView.getSettings().setJavaScriptEnabled(true);
  68.         codePunkerWebView.getSettings().setUserAgentString("Codepunker.com/0.1 (http://codepunker.com/CodePunker/; info@codepunker.com)"); //change the useragent I've set up to whatever you want as your user agent string
  69.         codePunkerWebView.loadUrl("http://www.codepunker.com"); //change this to your own website url
  70.       }
  71.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top