| | |
| | | package com.weikou.beibeivideo.ui.mine; |
| | | |
| | | import android.app.Activity; |
| | | import android.app.AlertDialog; |
| | | import android.app.Notification; |
| | | import android.app.NotificationChannel; |
| | |
| | | webview.addJavascriptInterface(new BWJavaInterface(this, webview), "yestv"); |
| | | } |
| | | |
| | | private boolean needSetResult = false; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | |
| | | String url = getIntent().getStringExtra("url"); |
| | | // String url="http://192.168.3.122:8848/buwan-web/BuWanWeb/vip/index.html"; |
| | | webview.loadUrl(url); |
| | | needSetResult = getIntent().getBooleanExtra("result", false); |
| | | } |
| | | |
| | | // 文件下载监听 |
| | |
| | | super.onResume(); |
| | | MobclickAgent.onPageStart("网页"); |
| | | // webview.reload(); |
| | | if(webview!=null){ |
| | | if (webview != null) { |
| | | webview.loadUrl("javascript:onResume()"); |
| | | } |
| | | } |
| | |
| | | switch (v.getId()) { |
| | | case R.id.tv_top_bar_left: { |
| | | if (!webview.canGoBack()) |
| | | finish(); |
| | | finishPage(); |
| | | else { |
| | | webview.goBack(); |
| | | } |
| | | } |
| | | break; |
| | | case R.id.tv_top_bar_left2: { |
| | | finish(); |
| | | finishPage(); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private void finishPage() { |
| | | if (needSetResult) |
| | | setResult(Activity.RESULT_OK); |
| | | finish(); |
| | | } |
| | | |
| | | // 设置回退 |
| | |
| | | if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) { |
| | | webview.goBack(); // goBack()表示返回WebView的上一页面 |
| | | return true; |
| | | } else { |
| | | if (keyCode == KeyEvent.KEYCODE_BACK) { |
| | | finishPage(); |
| | | } |
| | | } |
| | | return super.onKeyDown(keyCode, event); |
| | | } |