android端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FullscreenActivity.java 4.3 KiB

3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
1 年之前
2 年之前
2 年之前
1 年之前
2 年之前
2 年之前
2 年之前
1 年之前
2 年之前
1 年之前
2 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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:84/index"); //WebView载入该url地址的页面并显示。
  37. /* 上边url是各个APP项目的入口地址
  38. 事项审批 http://116.255.223.226:82/yinnongLogin 图标 ic_launcher_sxsp 或者 ic_launcher_yhzl
  39. 阳光村务(村级事项) http://116.255.223.226:82/sunVillage_info/login 图标 ic_launcher_ygcw
  40. 大托管 http://218.59.175.43:96/agriculturalTrusteeship/index 图标 ic_launcher_dtg
  41. 产权交易 http://116.255.223.226:82/index 图标 ic_launcher_cqjy
  42. 农业执法 http://116.255.223.226:82/lawEnforcement/login 图标 ic_launcher_nyzf
  43. 宅基地审批(乌市版) https://36.134.89.93:82/zjdLogin 图标 ic_launcher_zjd
  44. 宅基地调查 http://116.255.223.226:82/homesteadLogin 图标 ic_launcher_zjddc
  45. 两清三化 http://116.255.223.226:89/homestead/login 图标 ic_launcher_2q3h
  46. 网上家园(废) http://116.255.223.226:82/onlineHomeLogin 图标 ic_launcher_white
  47. 确权调查 http://116.255.223.226:82/contracted/login 图标 ic_launcher_qqdc
  48. */
  49. }
  50. @Override
  51. protected void onPause() {
  52. mAgentWeb.getWebLifeCycle().onPause();
  53. super.onPause();
  54. }
  55. @Override
  56. protected void onResume() {
  57. mAgentWeb.getWebLifeCycle().onResume();
  58. super.onResume();
  59. }
  60. @Override
  61. protected void onDestroy() {
  62. mAgentWeb.getWebLifeCycle().onDestroy();
  63. super.onDestroy();
  64. }
  65. @Override
  66. public boolean onKeyDown(int keyCode, KeyEvent event) {
  67. // if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {
  68. // mWebView.goBack();
  69. // return true;
  70. // }
  71. if (mAgentWeb.handleKeyEvent(keyCode, event)) {
  72. return true;
  73. }
  74. return super.onKeyDown(keyCode, event);
  75. }
  76. @Override
  77. protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
  78. super.onActivityResult(requestCode, resultCode, data);
  79. }
  80. }