android端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

85 wiersze
3.3 KiB

  1. package com.nsgk.ruralWeb;
  2. import android.annotation.SuppressLint;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.view.KeyEvent;
  6. import android.view.ViewGroup;
  7. import android.widget.LinearLayout;
  8. import android.widget.RelativeLayout;
  9. import com.just.agentweb.AgentWeb;
  10. import com.just.agentweb.DefaultWebClient;
  11. import androidx.annotation.Nullable;
  12. import androidx.appcompat.app.AppCompatActivity;
  13. /**
  14. * An example full-screen activity that shows and hides the system UI (i.e.
  15. * status bar and navigation/system bar) with user interaction.
  16. */
  17. public class FullscreenActivity extends AppCompatActivity {
  18. private AgentWeb mAgentWeb;
  19. @SuppressLint("SetJavaScriptEnabled")
  20. @Override
  21. protected void onCreate(Bundle savedInstanceState) {
  22. super.onCreate(savedInstanceState);
  23. setContentView(R.layout.activity_fullscreen);
  24. // init();
  25. mAgentWeb = AgentWeb.with(this)//
  26. .setAgentWebParent((RelativeLayout) findViewById(R.id.ll), -1, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))//传入AgentWeb的父控件。
  27. .useDefaultIndicator(-1, 3)//设置进度条颜色与高度,-1为默认值,高度为2,单位为dp。
  28. .setWebViewClient(new com.just.agentweb.WebViewClient() {
  29. })//WebViewClient , 与 WebView 使用一致 ,但是请勿获取WebView调用setWebViewClient(xx)方法了,会覆盖AgentWeb DefaultWebClient,同时相应的中间件也会失效。
  30. .setSecurityType(AgentWeb.SecurityType.STRICT_CHECK) //严格模式 Android 4.2.2 以下会放弃注入对象 ,使用AgentWebView没影响。
  31. .setMainFrameErrorView(R.layout.agentweb_error_page, -1) //参数1是错误显示的布局,参数2点击刷新控件ID -1表示点击整个布局都刷新, AgentWeb 3.0.0 加入。
  32. .setOpenOtherPageWays(DefaultWebClient.OpenOtherPageWays.ASK)//打开其他页面时,弹窗质询用户前往其他应用 AgentWeb 3.0.0 加入。
  33. .interceptUnkownUrl() //拦截找不到相关页面的Url AgentWeb 3.0.0 加入。
  34. .createAgentWeb()//创建AgentWeb。
  35. .ready()//设置 WebSettings。
  36. .go("http://218.59.175.43:96/agriculturalTrusteeship/index"); //WebView载入该url地址的页面并显示。
  37. }
  38. @Override
  39. protected void onPause() {
  40. mAgentWeb.getWebLifeCycle().onPause();
  41. super.onPause();
  42. }
  43. @Override
  44. protected void onResume() {
  45. mAgentWeb.getWebLifeCycle().onResume();
  46. super.onResume();
  47. }
  48. @Override
  49. protected void onDestroy() {
  50. mAgentWeb.getWebLifeCycle().onDestroy();
  51. super.onDestroy();
  52. }
  53. @Override
  54. public boolean onKeyDown(int keyCode, KeyEvent event) {
  55. // if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {
  56. // mWebView.goBack();
  57. // return true;
  58. // }
  59. if (mAgentWeb.handleKeyEvent(keyCode, event)) {
  60. return true;
  61. }
  62. return super.onKeyDown(keyCode, event);
  63. }
  64. @Override
  65. protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
  66. super.onActivityResult(requestCode, resultCode, data);
  67. }
  68. }