コード例 #1
2
ファイル: NinjaWebView.java プロジェクト: treejames/BBrowser
  private synchronized void initWebSettings() {

    if (android.os.Build.VERSION.SDK_INT >= 21) WebView.enableSlowWholeDocumentDraw();

    WebSettings webSettings = getSettings();
    userAgentOriginal = webSettings.getUserAgentString();

    webSettings.setAllowContentAccess(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setAllowFileAccessFromFileURLs(true);
    webSettings.setAllowUniversalAccessFromFileURLs(true);

    webSettings.setAppCacheEnabled(true);
    webSettings.setAppCachePath(context.getCacheDir().toString());
    webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
    webSettings.setDatabaseEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setGeolocationDatabasePath(context.getFilesDir().toString());

    webSettings.setSupportZoom(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);

    webSettings.setDefaultTextEncodingName(BrowserUnit.URL_ENCODING);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      webSettings.setLoadsImagesAutomatically(true);
    } else {
      webSettings.setLoadsImagesAutomatically(false);
    }
  }
コード例 #2
0
ファイル: HotFashionActivity.java プロジェクト: ICoi/NJND_App
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_hot_fashion);
   webview = (WebView) findViewById(R.id.webview);
   WebSettings s = webview.getSettings();
   s.setJavaScriptEnabled(true);
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
     s.setAllowUniversalAccessFromFileURLs(true);
     s.setAllowFileAccessFromFileURLs(true);
   }
   webview.setWebViewClient(new WebClient()); // �������α׷����� ���� url ó��
   WebSettings set = webview.getSettings();
   set.setJavaScriptEnabled(true);
   webview.loadUrl("http://namjungnaedle123.cafe24.com:3000/web/hot_fashion_list");
 }
コード例 #3
0
  // reload
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    webview = (WebView) findViewById(R.id.webview);
    webview.setWebViewClient(new MyWebViewClient());

    // Enable JS
    WebSettings webSettings = webview.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setAllowFileAccessFromFileURLs(true);
    webSettings.setAllowUniversalAccessFromFileURLs(true);

    webview.setWebChromeClient(new WebChromeClient());

    // Enable access to all methods in JS within WebAppInterface
    webview.addJavascriptInterface(new WebAppInterface(this), "FB");

    webview.loadUrl("file:///android_asset/dist/index.html");
  }
コード例 #4
0
  // @TargetApi(Build.VERSION_CODES.KITKAT)
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_welcome);

    mWebView = (WebView) findViewById(R.id.welcomeWebView);
    username = (EditText) findViewById(R.id.userName);
    password = (EditText) findViewById(R.id.password);
    // welcomeTitle = (TextView)findViewById(R.id.welcomeTitle);

    autoSignIn();

    // String htmlCode = "<h1> <a href=\"#\"> WAFFLE </a> </h1>";

    // welcomeTitle.setText(Html.fromHtml(htmlCode));

    // Force links and redirects to open
    // in the WebView instead of in a browser
    mWebView.setWebViewClient(new WebViewClient());
    // Stop local links and redirects from
    // opening in browser instead of WebView
    mWebView.setWebViewClient(new MyAppWebViewClient());

    mWebView.loadUrl(webUrl);
    // Enable Javascript
    WebSettings webSettings = mWebView.getSettings();

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
      webSettings.setAllowFileAccessFromFileURLs(true);
      webSettings.setAllowUniversalAccessFromFileURLs(true);
      webSettings.setTextZoom(
          webSettings.getTextZoom() + 90); // possibly creates not debuggable error
    }

    webSettings.setJavaScriptEnabled(true);
    //   mWebView.setWebContentsDebuggingEnabled(true);
    mWebView.setWebChromeClient(new WebChromeClient());

    // Log in button click handler
    Button loginButton = (Button) findViewById(R.id.loginBtt);
    loginButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            // Starts an intent of the log in activity
            // startActivity(new Intent(WelcomeActivity.this, LoginActivity.class));
            login();
          }
        });

    // Sign up button click handler
    Button signupButton = (Button) findViewById(R.id.signUpBttn);
    signupButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            // Starts an intent for the sign up activity
            Intent intent = new Intent(WelcomeActivity.this, SignUpActivity.class);
            intent.putExtra("userName", username.getText().toString().trim());
            intent.putExtra("password", password.getText().toString().trim());
            startActivity(intent);
            finish();
          }
        });

    /*
        @Override
        public void onBackPressed() {
            if(mWebView.canGoBack()) {
                mWebView.goBack();
            } else {
                super.onBackPressed();
            }
    */

  }