Esempio n. 1
0
 @SuppressLint({"JavascriptInterface"})
 public JDShopView(Context paramContext) {
   super(paramContext);
   setBackgroundColor(17170443);
   webView = new WebView(paramContext);
   webView.setWebChromeClient(new WebChromeClient() {});
   webView.setWebViewClient(new WebViewClient() {});
   WebSettings localWebSettings = webView.getSettings();
   localWebSettings.setJavaScriptEnabled(true);
   localWebSettings.setJavaScriptCanOpenWindowsAutomatically(true);
   localWebSettings.setAppCacheEnabled(false);
   localWebSettings.setJavaScriptEnabled(true);
   addView(webView);
 }
Esempio n. 2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    webView = (WebView) findViewById(R.id.webView);
    webView.loadUrl("file:///android_asset/example.html");
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);

    webView.getSettings().setDomStorageEnabled(true);

    webView.getSettings().setAppCacheMaxSize(1024 * 1024 * 8);
    String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
    webView.getSettings().setAppCachePath(appCachePath);
    webView.getSettings().setAllowFileAccess(true);
    webView.getSettings().setAppCacheEnabled(true);

    webView.setWebChromeClient(
        new WebChromeClient() {

          @Override
          public void onConsoleMessage(String message, int lineNumber, String sourceID) {
            super.onConsoleMessage(message, lineNumber, sourceID);
            Log.d("MyApplication", message + " -- From line " + lineNumber + " of " + sourceID);
          }
        });
  }
  @SuppressLint("SetJavaScriptEnabled")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getActionBar().setDisplayHomeAsUpEnabled(true);

    Bundle bundle = getIntent().getExtras();
    String url = bundle.getString("url");
    String title = bundle.getString("title");
    current_url = url;

    WebViewActivity.this.setTitle(title);

    final Context myApp = this;
    setContentView(R.layout.activity_webview);

    CookieSyncManager.createInstance(myApp);

    WebSettings settings = getWebView().getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    // settings.setLoadWithOverviewMode(true);
    settings.setUseWideViewPort(true);

    final WebView webview = (WebView) getWebView();
    webview.setWebViewClient(new MyWebViewClient());
    webview.setWebChromeClient(new MyWebChromeClient());

    webview.loadUrl(url);
  }
Esempio n. 4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ButterKnife.bind(this);
    mContext = this;
    mUrl = getIntent().getStringExtra(EXTRA_URL);
    mTitle = getIntent().getStringExtra(EXTRA_TITLE);

    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setAppCacheEnabled(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setSupportZoom(true);
    mWebView.setWebChromeClient(new ChromeClient());
    mWebView.setWebViewClient(new LoveClient());

    mWebView.loadUrl(mUrl);

    mTextSwitcher.setFactory(
        () -> {
          TextView textView = new TextView(this);
          textView.setTextAppearance(this, R.style.WebTitle);
          textView.setSingleLine(true);
          textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
          textView.postDelayed(() -> textView.setSelected(true), 1738);
          return textView;
        });
    mTextSwitcher.setInAnimation(this, android.R.anim.fade_in);
    mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out);
    if (mTitle != null) setTitle(mTitle);
  }
Esempio n. 5
0
 public void initWebview(WebView paramWebView) {
   WebSettings localWebSettings = paramWebView.getSettings();
   localWebSettings.setJavaScriptEnabled(true);
   if (Build.VERSION.SDK_INT > 7) localWebSettings.setPluginState(WebSettings.PluginState.ON);
   localWebSettings.setSupportZoom(true);
   localWebSettings.setBuiltInZoomControls(true);
   localWebSettings.setAllowFileAccess(true);
   localWebSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
   localWebSettings.setUseWideViewPort(true);
   if (Build.VERSION.SDK_INT >= 8) {
     localWebSettings.setLoadWithOverviewMode(true);
     localWebSettings.setDatabaseEnabled(true);
     localWebSettings.setDomStorageEnabled(true);
     localWebSettings.setGeolocationEnabled(true);
     localWebSettings.setAppCacheEnabled(true);
   }
   if (Build.VERSION.SDK_INT >= 11) ;
   try {
     Class[] arrayOfClass = new Class[1];
     arrayOfClass[0] = Boolean.TYPE;
     Method localMethod =
         WebSettings.class.getDeclaredMethod("setDisplayZoomControls", arrayOfClass);
     localMethod.setAccessible(true);
     Object[] arrayOfObject = new Object[1];
     arrayOfObject[0] = Boolean.valueOf(false);
     localMethod.invoke(localWebSettings, arrayOfObject);
     return;
   } catch (Exception localException) {
     com.taobao.newxp.common.Log.e(ExchangeConstants.LOG_TAG, "", localException);
   }
 }
Esempio n. 6
0
 @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");
 }
Esempio n. 7
0
  /**
   * 初始化
   *
   * @param web_view
   * @param activity
   * @return
   */
  public static WebView WebSettingInit(WebView web_view, final Activity activity) {
    WebSettings ws = web_view.getSettings();
    ws.setJavaScriptEnabled(true); // 支持js
    ws.setBuiltInZoomControls(false); // 支持缩放按钮
    ws.setUseWideViewPort(true); // 设置此属性,可任意比例缩放 将图片调整到适合webview的大小
    ws.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
    ws.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
    ws.setSupportZoom(false); // 支持缩放
    // 设置 缓存模式
    ws.setCacheMode(WebSettings.LOAD_NO_CACHE); // 关闭webview中缓存

    web_view.clearCache(true);
    web_view.setTag(true);
    // 开启 DOM storage API 功能
    ws.setDomStorageEnabled(true);

    ws.setRenderPriority(RenderPriority.HIGH);
    // 开启 database storage API 功能
    ws.setDatabaseEnabled(false);

    web_view.setWebChromeClient(
        new WebChromeClient() {

          @Override
          public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
            return super.onJsAlert(view, url, message, result);
          }
        });
    return web_view;
  }
  @Override
  public void initComponents() {
    wvUrl = (WebView) innerView.findViewById(R.id.wvUrl);
    WebSettings ws = wvUrl.getSettings();
    ws.setAllowFileAccess(true);
    ws.setAppCacheEnabled(true);
    ws.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    ws.setBuiltInZoomControls(false);
    ws.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
    ws.setDisplayZoomControls(false);
    ws.setJavaScriptEnabled(true);
    ws.setSupportZoom(false);
    ws.setDefaultTextEncodingName("GBK");

    wvUrl.setWebViewClient(
        new WebViewClient() {
          @Override
          public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
            view.post(
                new Runnable() {

                  @Override
                  public void run() {
                    view.loadUrl(url);
                  }
                });
            return false;
          }
        });
    wvUrl.setWebChromeClient(new WebChromeClient());
  }
Esempio n. 9
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fun_everyday, container, false);
    menu = (ImageButton) view.findViewById(R.id.btn_header_left);
    menu.setOnClickListener(this);

    TextView headText = (TextView) view.findViewById(R.id.title_header_mid);
    headText.setText(R.string.text_menu_story);

    String url = "http://www.molegegu.com/im/webview.htm";

    mWebView = (WebView) view.findViewById(R.id.sub_xeb_webview);
    mWebView.loadUrl(url);
    mWebView.setWebViewClient(
        new WebViewClient() {

          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
          }
        });

    mProgressBar = (ProgressBar) view.findViewById(R.id.loadProgress);
    mWebView = (WebView) view.findViewById(R.id.sub_xeb_webview);
    mWebView.loadUrl(url);
    mWebView.setWebViewClient(
        new WebViewClient() {

          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
          }
        });
    // set the webview
    WebSettings settings = mWebView.getSettings();
    settings.setSupportZoom(true);
    settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    settings.setDefaultTextEncodingName("GBK");
    settings.setTextSize(TextSize.NORMAL);
    settings.setJavaScriptEnabled(true);
    settings.setUseWideViewPort(true);
    mWebView.setInitialScale(80);
    mWebView.setWebChromeClient(
        new WebChromeClient() {
          @Override
          public void onProgressChanged(WebView view, int newProgress) {
            if (newProgress > 0 && newProgress < 100) {
              mProgressBar.setVisibility(View.VISIBLE);
              mProgressBar.setProgress(newProgress);
            } else if (newProgress == 100) {
              mProgressBar.setVisibility(View.GONE);
            }
          }
        });
    mWebView.requestFocusFromTouch();
    return view;
  }
  @SuppressLint("SetJavaScriptEnabled")
  private void initWebView() {
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDefaultTextEncodingName("utf-8");
    mWebView.setWebViewClient(
        new WebViewClient() {
          public void onReceivedError(
              WebView view, int errorCode, String description, String failingUrl) {
            AppLog.e(T.EDITOR, description);
          }
        });
    mWebView.setWebChromeClient(
        new WebChromeClient() {
          public boolean onConsoleMessage(ConsoleMessage cm) {
            AppLog.e(
                T.EDITOR,
                cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId());
            return true;
          }

          @Override
          public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
            AppLog.e(T.EDITOR, message);
            return true;
          }

          @Override
          public void onConsoleMessage(String message, int lineNumber, String sourceId) {
            AppLog.e(T.EDITOR, message + " -- from line " + lineNumber + " of " + sourceId);
          }
        });
    String htmlEditor = getHtmlEditor();
    mWebView.loadDataWithBaseURL("file:///android_asset/", htmlEditor, "text/html", "utf-8", "");
  }
Esempio n. 11
0
  private void initViewer() {
    settings.setLoadsImagesAutomatically(true);
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    settings.setLightTouchEnabled(true);
    settings.setBuiltInZoomControls(true);
    settings.setJavaScriptEnabled(true);

    viewer.setInitialScale(0);
    viewer.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    viewer.setHorizontalScrollBarEnabled(false);
    viewer.setVerticalScrollBarEnabled(false);
    viewer.setBackgroundColor(0x000000);
    viewer.clearCache(true);
    viewer.setFocusable(false);

    viewer.setWebViewClient(
        new WebViewClient() {
          @Override
          public void onPageFinished(WebView view, String url) {}

          @Override
          public void onReceivedError(
              WebView view, int errorCode, String description, String failingUrl) {}

          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
          }
        });
  }
  /** Called to instantiate the view. Creates and returns the WebView. */
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (mWebView != null) {
      mWebView.destroy();
    }
    mWebView = new WebView(getActivity());
    View myFragmentView = inflater.inflate(R.layout.news_feed_fragment, container, false);
    progress = ProgressDialog.show(getActivity(), "Loading", "Please wait...", true);

    mWebView.setWebViewClient(
        new InnerWebViewClient() {
          public void onPageFinished(WebView view, String url) {
            if (progress != null) {
              progress.dismiss();
            }
            super.onPageFinished(view, url);
          }
        }); // forces it to open in app
    mWebView.loadUrl(mUrl);
    mIsWebViewAvailable = true;
    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);

    return mWebView;
  }
 private dd(Context context, ab abVar, boolean z, boolean z2, l lVar, db dbVar) {
   super(context);
   this.mg = new Object();
   this.pZ = context;
   this.mF = abVar;
   this.qb = z;
   this.nP = lVar;
   this.mG = dbVar;
   setBackgroundColor(0);
   WebSettings settings = getSettings();
   settings.setJavaScriptEnabled(true);
   settings.setSavePassword(false);
   settings.setSupportMultipleWindows(true);
   settings.setJavaScriptCanOpenWindowsAutomatically(true);
   cv.a(context, dbVar.pU, settings);
   if (VERSION.SDK_INT >= 17) {
     cx.a(getContext(), settings);
   } else if (VERSION.SDK_INT >= 11) {
     cw.a(getContext(), settings);
   }
   setDownloadListener(this);
   if (VERSION.SDK_INT >= 11) {
     this.pY = new dg(this, z2);
   } else {
     this.pY = new de(this, z2);
   }
   setWebViewClient(this.pY);
   if (VERSION.SDK_INT >= 14) {
     setWebChromeClient(new dh(this));
   } else if (VERSION.SDK_INT >= 11) {
     setWebChromeClient(new df(this));
   }
   bf();
 }
Esempio n. 14
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lesson);

    wv = (WebView) findViewById(R.id.wv_lesson);
    WebSettings settings = wv.getSettings();
    settings.setJavaScriptEnabled(true);

    pref = getSharedPreferences("user", Context.MODE_PRIVATE);

    new Thread() {
      public void run() {
        String s = null;
        try {
          s =
              MyUtils.postHtml(
                  "http://awaydian.top/app/index.php?m=njust&a=lesson",
                  "id="
                      + pref.getString("jwc_id", null)
                      + "&psw="
                      + pref.getString("jwc_psw", null),
                  null);

        } catch (Exception e) {
          s = "网络出现问题";
          e.printStackTrace();
        }
        Message msg = new Message();
        msg.obj = s;
        handler.sendMessage(msg);
      }
    }.start();
  }
Esempio n. 15
0
  @SuppressLint({"JavascriptInterface", "SetJavaScriptEnabled"})
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_layout);

    mWebView = (WebView) findViewById(R.id.id_webview);
    mText = (TextView) findViewById(R.id.id_tv);
    mButton = (Button) findViewById(R.id.id_btn);

    mButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            mWebView.loadUrl("javascript:javacalljs()");
          }
        });

    WebSettings webSettings = mWebView.getSettings();

    webSettings.setJavaScriptEnabled(true);
    webSettings.setSupportZoom(true);
    mWebView.setWebViewClient(new WebViewClient());
    mWebView.setWebChromeClient(new MyWebChromeClient());

    mWebView.addJavascriptInterface(new MyJavaScriptInterface(), "android");
    mWebView.loadUrl("file:///android_asset/index.html"); // 转义符
  }
Esempio n. 16
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.showevent_activity);
    layout = (LinearLayout) this.findViewById(R.id.show_mark);
    infotitle = (TextView) findViewById(R.id.toolbar_title);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setLogo(R.mipmap.ic_launcher);
    setSupportActionBar(toolbar);
    final ActionBar ab = getSupportActionBar();
    ab.setDisplayShowTitleEnabled(false);
    getSupportActionBar()
        .setDisplayShowHomeEnabled(
            true); // BACK botton which just available on Android 5.0, and have to set
                   // parentActivity.

    Bundle extras = getIntent().getExtras();

    String myURL = extras.getString("url");
    infotitle.setText(extras.getString("title"));

    WebView myBrowser = (WebView) findViewById(R.id.webView);

    WebSettings websettings = myBrowser.getSettings();
    websettings.setSupportZoom(true);
    websettings.setBuiltInZoomControls(true);
    websettings.setJavaScriptEnabled(true);

    myBrowser.setWebViewClient(new WebViewClient());
    myBrowser.loadUrl(myURL);
  }
Esempio n. 17
0
 private void setupWebview() {
   webview = (WebView) findViewById(R.id.main_webview);
   WebSettings webSettings = webview.getSettings();
   webSettings.setJavaScriptEnabled(true);
   webview.addJavascriptInterface(this, "hostapp");
   webview.loadUrl(getResources().getString(R.string.app_url));
 }
Esempio n. 18
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d();
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
    mBrowser = this;

    mVizWebViewClient = new VizWebViewClient(this);
    mWebChromeClient = new VizWebChromeClient(this);

    mVizWebView = new WebView(getActivity()); // get attributes?
    mVizWebView.setWebViewClient(mVizWebViewClient);
    mVizWebView.setWebChromeClient(mWebChromeClient);
    if (savedInstanceState != null) {
      Log.d("restoring web view state");
      mVizWebView.restoreState(savedInstanceState);
    }
    WebSettings s = mVizWebView.getSettings();
    s.setJavaScriptEnabled(true);
    s.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    s.setBuiltInZoomControls(true);
    s.setUseWideViewPort(true);
    s.setLoadWithOverviewMode(true);
    s.setSaveFormData(true);

    mVizWebView.setId(61377); // PhoneWindow complained about no id (focus couldn't be saved)

    // Loading homepage here results in an exception on ICS, not sure why.
    // Update: post-poning until onCreatingView doesn't entirely fix the
    // issue either.
    // mVizWebView.loadUrl(defaultURL);
  }
Esempio n. 19
0
  @SuppressLint({"NewApi", "SetJavaScriptEnabled"})
  private void loadWebView() {
    // 实例化WebView对象
    // webview = new MyWebView(WebViewActivity.this);
    LogUtil.i(TAG, "loadWebView===实例化WebView===");
    webview = (MyWebView) findViewById(R.id.id_webview);
    new MobclickAgentJSInterface(this, webview);

    WebSettings webSettings = webview.getSettings();
    // 设置WebView属性,能够执行Javascript脚本
    webSettings.setJavaScriptEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    //
    webSettings.setUseWideViewPort(true); // 关键点
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setAppCacheEnabled(true);

    webSettings.setAppCacheMaxSize(8 * 1024 * 1024); // 8MB
    // webSettings.setAppCachePath(Constants.WEBVIEW_CACHE_DIR );
    String appCacheDir =
        this.getApplicationContext().getDir("cache", Context.MODE_PRIVATE).getPath();
    webSettings.setAppCachePath(appCacheDir);
    webSettings.setAllowFileAccess(true);
    webSettings.setDomStorageEnabled(true);

    webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);

    // js调用安卓方法
    webview.addJavascriptInterface(this, "RedirectListner");
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gives_detail);
    iv = (ImageView) findViewById(R.id.iv);
    tv = (TextView) findViewById(R.id.tv);
    wv = (WebView) findViewById(R.id.wv);
    Intent intent = getIntent();
    gives = intent.getParcelableExtra("gives");
    String imgUrl = gives.getGImgUrl();
    ImageLoaderUtil.display(imgUrl, iv);
    tv.setText(gives.getGDescription());

    WebSettings settings = wv.getSettings();
    settings.setJavaScriptEnabled(true);
    wv.setWebChromeClient(new WebChromeClient());
    wv.setWebViewClient(new WebViewClient());
    String url =
        "http://m.amap.com/?q="
            + gives.getGLatitude()
            + ","
            + gives.getGLongitude()
            + "&name="
            + gives.getGLocation()
            + "&view=detail"
            + "&key=5c8577b8ad3565cc7ea726272888efca";
    wv.loadUrl(url);
  }
 /** * 初始化内容控件 */
 private void initWeb() {
   // TODO Auto-generated method stub
   String release = android.os.Build.VERSION.RELEASE;
   release = release.substring(0, 3);
   if ("4.4".equals(release)) {
     web_content.setWebViewClient(new MyWebViewClient());
   } else {
     web_content.setVisibility(View.VISIBLE);
     WebSettings ws = web_content.getSettings();
     ws.setJavaScriptEnabled(true);
     ws.setAllowFileAccess(true);
     ws.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
     ws.setDefaultTextEncodingName("utf-8");
     ws.setTextSize(TextSize.NORMAL);
     ws.setAppCacheEnabled(false);
     ws.setDomStorageEnabled(true);
     if (android.os.Build.VERSION.SDK_INT >= 8) {
       ws.setPluginState(PluginState.ON);
     }
     ws.setRenderPriority(RenderPriority.HIGH);
     web_content.setWebViewClient(new WebViewClientDemo());
     web_content.setWebChromeClient(new WebViewChromeClientDemo());
     web_content.loadDataWithBaseURL("", unit.getIntroduce(), "text/html", "utf-8", null);
   }
 }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Window win = this.getWindow();
    win.setFlags(
        WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

    requestWindowFeature(Window.FEATURE_CONTEXT_MENU);
    setContentView(R.layout.bar_code);

    if (isOnline() && getAutoUpdateSetting()) {
      AutoUpdate();
      Log.i(TAG, "online");
    } else Log.i(TAG, "offline");

    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    String databasePath =
        this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
    Log.i(TAG, databasePath);

    mpAudio = new MediaPlayer();
    mpAudio = MediaPlayer.create(BarcodeDemoActivity.this, R.raw.bb);
    mpAudio.setVolume(100.0f, 100.0f);

    MainWebView = (WebView) findViewById(R.id.barcode);
    MainWebView.requestFocus(View.FOCUS_DOWN);
    MainWebView.addJavascriptInterface(new runCallJavaScript(), JSInterface);

    WebSettings settings = MainWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDatabaseEnabled(true);
    settings.setDatabasePath(databasePath + File.separator + "BarcodeDemoDB");

    MainWebView.loadUrl(WebPageUrl + "?lang=" + getLangCode(getLocale()));

    MainWebView.setWebChromeClient(
        new WebChromeClient() {
          @Override
          public void onExceededDatabaseQuota(
              String url,
              String databaseIdentifier,
              long currentQuota,
              long estimatedSize,
              long totalUsedQuota,
              QuotaUpdater quotaUpdater) {
            Log.i(TAG, "estimatedSize=" + estimatedSize);
            quotaUpdater.updateQuota(estimatedSize * 2);
          }
        });
    MainWebView.setWebViewClient(
        new WebViewClient() {
          @Override
          public void onPageFinished(WebView webView, String url) {
            // String lang = getLangCode(getLocale());
            // MainWebView.loadUrl("javascript:setLanguage('"+lang+"');");
          }
        });
  }
Esempio n. 23
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ConnectivityManager connec =
        (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    if (connec != null && (connec.getNetworkInfo(1).isAvailable() == true)
        || (connec.getNetworkInfo(0).isAvailable() == true)) {
      this.setTitle("New Friend..");

      Parse.initialize(
          this,
          "PV07xPdLpxzJKBKUS2UP6iJ0W9GbEHvmfPMMQovz",
          "OPxrcJKt4Pe26WHvCAeuI86hnGzXjOlO1NmyfJyP");

      WebView myWebView = (WebView) findViewById(R.id.webView1);
      myWebView.loadUrl("http://www.markevansjr.com/AndroidApp/index.html");

      WebSettings webSettings = myWebView.getSettings();
      webSettings.setJavaScriptEnabled(true);
      myWebView.addJavascriptInterface(new WebAppInterface(this), "Android");

      myWebView.setWebViewClient(new WebViewClient());
    } else {
      Toast toast = Toast.makeText(this, "NO CONNECTION", Toast.LENGTH_SHORT);
      toast.show();
    }
  }
Esempio n. 24
0
 public static void initializeSettings(WebSettings settings, Context context) {
   settings.setJavaScriptEnabled(true);
   settings.setJavaScriptCanOpenWindowsAutomatically(true);
   settings.setUserAgentString(settings.getUserAgentString() + DB.USER_AGENT);
   settings.setSupportMultipleWindows(true);
   settings.setSaveFormData(false);
   settings.setSavePassword(false); // 设置为true,系统会弹出AlertDialog确认框
   if (API < 18) {
     settings.setAppCacheMaxSize(Long.MAX_VALUE);
   }
   if (API < 17) {
     settings.setEnableSmoothTransition(true);
   }
   if (API < 19) {
     settings.setDatabasePath(context.getFilesDir().getAbsolutePath() + "/databases");
   }
   settings.setDomStorageEnabled(true);
   settings.setAppCachePath(context.getCacheDir().toString());
   settings.setAppCacheEnabled(true);
   settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
   settings.setGeolocationDatabasePath(context.getCacheDir().getAbsolutePath());
   settings.setAllowFileAccess(true);
   settings.setDatabaseEnabled(true);
   settings.setSupportZoom(true);
   settings.setBuiltInZoomControls(true);
   settings.setDisplayZoomControls(false);
   settings.setAllowContentAccess(true);
   settings.setDefaultTextEncodingName("utf-8");
   /*if (API > 16) {
   	settings.setAllowFileAccessFromFileURLs(false);
   	settings.setAllowUniversalAccessFromFileURLs(false);
   }*/
 }
Esempio n. 25
0
  /**
   * Convenience method to set some generic defaults for a given WebView
   *
   * @param webView
   */
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private void setUpWebViewDefaults(WebView webView) {
    WebSettings settings = webView.getSettings();

    // Enable Javascript
    settings.setJavaScriptEnabled(true);

    // Use WideViewport and Zoom out if there is no viewport defined
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);

    // Enable pinch to zoom without the zoom buttons
    settings.setBuiltInZoomControls(true);

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
      // Hide the zoom controls for HONEYCOMB+
      settings.setDisplayZoomControls(false);
    }

    // Enable remote debugging via chrome://inspect
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      WebView.setWebContentsDebuggingEnabled(true);
    }

    // We set the WebViewClient to ensure links are consumed by the WebView rather
    // than passed to a browser if it can
    webView.setWebViewClient(new WebViewClient());
  }
  @SuppressLint("SetJavaScriptEnabled")
  private void initView() {
    // TODO Auto-generated method stub
    product_detail_listview_image = (ImageView) findViewById(R.id.product_detail_listview_image);
    product_detail_listview_text_name =
        (TextView) findViewById(R.id.product_detail_listview_text_name);
    product_detail_listview_text_price =
        (TextView) findViewById(R.id.product_detail_listview_text_price);
    product_detail_listview_text_describe =
        (TextView) findViewById(R.id.product_detail_listview_text_describe);
    productWebView = (WebView) findViewById(R.id.product_webview);
    WebSettings webSettings = productWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);

    webViewUtil = new WebViewUtil();

    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    options =
        new DisplayImageOptions.Builder()
            .displayer(new RoundedBitmapDisplayer(0xff000000, 10))
            .cacheInMemory()
            .cacheOnDisc()
            .build();

    product_detail_listview_text_name.setText(product.getProductName());
    product_detail_listview_text_price.setText(product.getProductPrice());
    product_detail_listview_text_describe.setText(product.getProductDescribe());
    imageLoader.displayImage(product.getImageUrl(), product_detail_listview_image, options);
  }
  @SuppressWarnings("deprecation")
  @SuppressLint("SetJavaScriptEnabled")
  public static void loadUrlAdaptiveScreen(
      Context mContext, WebView webview, String url, boolean javaScriptEnabled) {
    WebSettings webSettings = webview.getSettings();
    webSettings.setJavaScriptEnabled(javaScriptEnabled);
    // 自适应屏幕
    // 第一种:
    // WebSetting settings = webView.getSettings();
    // settings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
    // 把所有内容放在webview等宽的一列中。(可能会出现页面中链接失效)
    // 第二种:
    // settings.setUseWideViewPort(true);
    // settings.setLoadWithOverviewMode(true);
    // 第三种:
    DisplayMetrics metrics = new DisplayMetrics();
    ((Activity) mContext).getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int mDensity = metrics.densityDpi;
    if (mDensity <= 120) {
      webSettings.setDefaultZoom(ZoomDensity.CLOSE);
    } else if (mDensity > 120 && mDensity < 240) {
      webSettings.setDefaultZoom(ZoomDensity.MEDIUM);
    } else if (mDensity >= 240) {
      webSettings.setDefaultZoom(ZoomDensity.FAR);
    }

    webview.setWebViewClient(new WebViewClient());
    webview.loadUrl(url);
  }
  private void loadAndPlayVideo() {
    if (popUpViewVideo == null) {
      popUpViewVideo = layoutInflater.inflate(R.layout.fragment_video, null);
      webView = (WebView) popUpViewVideo.findViewById(R.id.webview2);
      WebSettings webSettings = webView.getSettings();
      webSettings.setPluginState(WebSettings.PluginState.ON);
      webSettings.setJavaScriptEnabled(true);
      String html = getHTML(getVideoURL());

      webView.loadData(html, "text/html", "utf-8");
      webView.setWebViewClient(
          new WebViewClient() {

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
              return false;
            }

            @Override
            public void onPageFinished(WebView view, String url) {
              super.onPageFinished(view, url);
            }
          });

      videoPopup = popupWindow(popUpViewVideo, true);
    }
    mDrawerLayout.closeDrawer(mDrawerList);
  }
Esempio n. 29
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // 保持屏幕亮
    //		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    //				WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);
    webview = (WebView) super.findViewById(R.id.webView);
    progress = (ProgressBar) super.findViewById(R.id.progress);
    // progress.setVisibility(View.GONE);
    webview.setWebChromeClient(new WebChromeClientImpl(handler));
    webview.setWebViewClient(wc);
    // webview.setInitialScale(25);
    ws = webview.getSettings();
    ws.setJavaScriptCanOpenWindowsAutomatically(true);
    ws.setJavaScriptEnabled(true);
    ws.setPluginState(PluginState.ON);
    ws.setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
    Log.i("---", "加载");
    // ws.setSupportZoom(true);
    // ws.setBuiltInZoomControls(true);//设置支持缩放
    // ws.setUseWideViewPort(true);
    webview.loadUrl("http://aaaadc.com");
    // webview.loadUrl("http://www.oceanthree.hk/apps_shop/app_index.php");

  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // ------------------to be removed after connecting the activities

    Intent myIntent1 = new Intent(this, UserData.class);
    this.startActivity(myIntent1);

    // -------------

    final WebView myWebView = (WebView) findViewById(R.id.webView1);
    WebSettings webSettings = myWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    myWebView.setWebChromeClient(new WebChromeClient());

    final EditText url = (EditText) findViewById(R.id.editText1);

    final Button button = (Button) findViewById(R.id.button1);
    button.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            myWebView.loadUrl(" file:///android_asset/index.html");
          }
        });
  }