小编Yan*_*ick的帖子

没有互联网连接时强制关闭应用程序

我知道以前可能会问过这个问题,但我不知道如何使用这些答案使它们与我的应用程序一起使用。

我想检查应用程序的用户打开应用程序时是否存在互联网连接。我已经找到了一些方法来检查它,但是我对android开发是全新的,我只是不知道该怎么做。这是我当前的应用程序文件:

package com.pocket.line;

import com.pocket.line.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class AndroidMobileAppSampleActivity extends Activity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    WebView mainWebView = (WebView) findViewById(R.id.mainWebView);

    WebSettings webSettings = mainWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);

    mainWebView.setWebViewClient(new MyCustomWebViewClient());
    mainWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

    mainWebView.loadUrl("http://www.google.com/");
}

private class MyCustomWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
}
}
Run Code Online (Sandbox Code Playgroud)

如果没有连接,我想强制关闭该应用程序并显示警报。我发现可以检查此代码段:

    public boolean hasActiveInternetConnection() …
Run Code Online (Sandbox Code Playgroud)

android

4
推荐指数
1
解决办法
7885
查看次数

Internet Explorer 和 Firefox 未显示页面上的所有图像

由于某种原因,我的网站长期以来一直遇到一个奇怪的问题,但我仍然没有弄清楚是什么导致了这个问题。

这是我的网页在 Chrome 中的样子:(这也是它在任何浏览器中的样子):

这是它在 IE11 中的样子: 图2

正如您所看到的,左侧第三张图片没有显示,但在 Chrome 上它确实显示了。这种情况已经发生过多次。我已经检查了宽度和高度参数,所有这些都是正确的:但 IE 说我的图像的尺寸是 283x16px,而不是 349x240px(右键单击 > 属性)。

<img width="349" height="240" src="http://exofeed.nl/wp-content/uploads/2015/01/Belgian-film-student-travels-more-than-5000-miles-to-be-friends-with-a-complete-stranger__880-1-349x240.jpg" class="attachment-grid-post wp-post-image" alt="Belgian-film-student-travels-more-than-5000-miles-to-be-friends-with-a-complete-stranger__880 (1)" title="Man reist 8000 kilometer af om een compleet vreemde te ontmoeten van Facebook"/>
Run Code Online (Sandbox Code Playgroud)

出现问题的页面:http://exofeed.nl/ - 顺便说一下,我正在使用 wordpress。

以前有其他人遇到过这个问题吗?或者有人知道这可能是什么原因造成的吗?

更新:看起来它在 Firefox 上也不起作用......

我将不胜感激任何形式的帮助!

html firefox internet-explorer webp

3
推荐指数
1
解决办法
1636
查看次数

将PHP代码转换为Coldfusion

目前我正在学习一些Coldfusion编码,并且我将我整个旧的PHP网站转换为时尚的Coldfusion代码,但我坚持使用几行PH​​P并且我真的不知道我应该如何转换这些将代码行转换为正确的Coldfusion代码:

function access()   
{   
  $accesscode = $_GET["accesscode"];
  $time = (int)$_GET["time"];        
  $ip = $_GET["ip"];                

  // Time variable must be identical 
  if( time() < $time )  
      {  
      die("Locale time is ". (time()-$time) ."sec. is not correct.");  
      }  

 // Check client IP
  if( $ip <> $_SERVER["REMOTE_ADDR"] )  
      {  
      die("Client IP ".$_SERVER["REMOTE_ADDR"]." is not identical as ".$ip." used."); 
      }  

  // Time > 10 minutes is no access
  for ($c=0;$c<=3;$c++)   
    {   
    $t = substr(strftime("%Y%m%d%H%M", time()-($c*600)),0,11);   
    $hash = md5($ip. "9709f31be0". $t);   
    if( $hash == $accesscode ) …
Run Code Online (Sandbox Code Playgroud)

coldfusion

2
推荐指数
1
解决办法
1615
查看次数

标签 统计

android ×1

coldfusion ×1

firefox ×1

html ×1

internet-explorer ×1

webp ×1