我想实现通知,例如每当有新内容添加到网站时,它会向用户发送通知或触发某些单词。如果您可以发布真正有用的代码,谢谢。
public class NewsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_news);
String url = "https://www.example.com";
WebView web = (WebView) findViewById(R.id.webView4);
web.loadUrl(url);
final WebView mWebView = (WebView) findViewById(R.id.webView4);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
mWebView.getSettings().setSavePassword(true);
mWebView.getSettings().setSupportZoom(true);
mWebView.getSettings().setSaveFormData(true);
mWebView.getSettings().setSupportZoom(false);
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setSupportMultipleWindows(false);
mWebView.getSettings().setLightTouchEnabled(true);
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
webview.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading (WebView view, String url){
return true; }
});
mWebView.loadUrl("https://www.example.com");
}}