Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android ping URL(不打开)_Android_Url_Ping_Hit - Fatal编程技术网

android ping URL(不打开)

android ping URL(不打开),android,url,ping,hit,Android,Url,Ping,Hit,你好,我需要做的一件事就是。。。 点击我做过的任何URL public class UrlPinger extends AsyncTask<URL, Void, Void> { @Override protected Void doInBackground(URL... urls) { URL url = urls[0]; try { HttpURLConnection

你好,我需要做的一件事就是。。。 点击我做过的任何URL

public class UrlPinger extends AsyncTask<URL, Void, Void> {

        @Override
        protected Void doInBackground(URL... urls) {
            URL url = urls[0];

            try {
                HttpURLConnection urlConnection = (HttpURLConnection) url
                        .openConnection();
                urlConnection.connect();
                System.out.println("thisi si wie URL>>>"+url+"");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                System.out.println("ERROR "+e.getMessage()+"");
            }

            return null;

        }
给予 我的日志:

04-11 11:32:09.206: D/StatusBar.NetworkController(1154): refreshViews: Data not connected!! Set no data type icon
04-11 11:32:09.206: D/StatusBar.NetworkController(1154): refreshViews connected={ wifi } level=4 combinedSignalIconId=0x7f0200c1/com.android.systemui:drawable/stat_sys_wifi_signal_4_fully combinedActivityIconId=0x7f0200b1 mobileLabel=BSNL MOBILE wifiLabel=LeewayxxxxXXXXxxxxXXXX emergencyOnly=false combinedLabel=LeewayxxxxXXXXxxxxXXXX mAirplaneMode=false mDataActivity=0 mPhoneSignalIconId=0x7f0200a7 mDataDirectionIconId=0x0 mDataSignalIconId=0x7f0200a7 mDataTypeIconId=0x0 mNoSimIconId=0x0 mWifiIconId=0x7f0200c1 mBluetoothTetherIconId=0x108076a
04-11 11:32:09.206: D/StatusBar.NetworkController(1154): changing data overlay icon id to 2130837681
04-11 11:32:10.657: D/StateMachine(651): handleMessage: E msg.what=131155
04-11 11:32:10.657: D/StateMachine(651): processMsg: ConnectedState
04-11 11:32:10.657: D/WifiStateMachine(651): ConnectedState{ what=131155 when=-6ms arg1=1121 }
04-11 11:32:10.657: D/StateMachine(651): processMsg: L2ConnectedState
04-11 11:32:10.657: D/WifiStateMachine(651): L2ConnectedState{ what=131155 when=-9ms arg1=1121 }
04-11 11:32:10.657: I/wpa_supplicant(17672): wlan0: Control interface command 'SIGNAL_POLL'
04-11 11:32:10.667: D/StateMachine(651): handleMessage: X
04-11 11:32:11.208: W/SignalStrength(1154): getLTELevel - rsrp:2147483647 snr:2147483647 rsrpIconLevel:-1 snrIconLevel:-1
04-11 11:32:11.208: W/SignalStrength(1154): getLTELevel - rssi:99 rssiIconLevel:0
04-11 11:32:11.208: W/SignalStrength(1154): getTdScdmaLevel = 0
04-11 11:32:11.208: W/SignalStrength(1154): getGsmLevel=4
04-11 11:32:11.208: W/SignalStrength(1154): getLevel=4
04-11 11:32:11.208: D/StatusBar.NetworkController(1154): refreshViews: Data not connected!! Set no data type icon
04-11 11:32:11.208: D/StatusBar.NetworkController(1154): refreshViews connected={ wifi } level=4 combinedSignalIconId=0x7f0200c1/com.android.systemui:drawable/stat_sys_wifi_signal_4_fully combinedActivityIconId=0x0 mobileLabel=BSNL MOBILE wifiLabel=LeewayxxxxXXXXxxxxXXXX emergencyOnly=false combinedLabel=LeewayxxxxXXXXxxxxXXXX mAirplaneMode=false mDataActivity=0 mPhoneSignalIconId=0x7f0200a7 mDataDirectionIconId=0x0 mDataSignalIconId=0x7f0200a7 mDataTypeIconId=0x0 mNoSimIconId=0x0 mWifiIconId=0x7f0200c1 mBluetoothTetherIconId=0x108076a
04-11 11:32:11.218: D/StatusBar.NetworkController(1154): changing data overlay icon id to 0
04-11 11:32:13.681: D/StateMachine(651): handleMessage: E msg.what=131155
04-11 11:32:13.681: D/StateMachine(651): processMsg: ConnectedState
04-11 11:32:13.681: D/WifiStateMachine(651): ConnectedState{ what=131155 when=-3ms arg1=1121 }
04-11 11:32:13.681: D/StateMachine(651): processMsg: L2ConnectedState
04-11 11:32:13.681: D/WifiStateMachine(651): L2ConnectedState{ what=131155 when=-6ms arg1=1121 }
04-11 11:32:13.681: I/wpa_supplicant(17672): wlan0: Control interface command 'SIGNAL_POLL'
04-11 11:32:13.691: D/StateMachine(651): handleMessage: X
04-11 11:32:16.694: D/StateMachine(651): handleMessage: E msg.what=131155
04-11 11:32:16.694: D/StateMachine(651): processMsg: ConnectedState
04-11 11:32:16.694: D/WifiStateMachine(651): ConnectedState{ what=131155 when=-5ms arg1=1121 }
04-11 11:32:16.694: D/StateMachine(651): processMsg: L2ConnectedState
04-11 11:32:16.694: D/WifiStateMachine(651): L2ConnectedState{ what=131155 when=-7ms arg1=1121 }
04-11 11:32:16.694: I/wpa_supplicant(17672): wlan0: Control interface command 'SIGNAL_POLL'
04-11 11:32:16.714: D/StateMachine(651): handleMessage: X
04-11 11:32:19.707: D/StateMachine(651): handleMessage: E msg.what=131155
04-11 11:32:19.707: D/StateMachine(651): processMsg: ConnectedState
04-11 11:32:19.707: D/WifiStateMachine(651): ConnectedState{ what=131155 when=-4ms arg1=1121 }
04-11 11:32:19.717: D/StateMachine(651): processMsg: L2ConnectedState
04-11 11:32:19.717: D/WifiStateMachine(651): L2ConnectedState{ what=131155 when=-6ms arg1=1121 }
04-11 11:32:19.717: I/wpa_supplicant(17672): wlan0: Control interface command 'SIGNAL_POLL'
04-11 11:32:19.727: D/StateMachine(651): handleMessage: X
04-11 11:32:22.730: D/StateMachine(651): handleMessage: E msg.what=131155
04-11 11:32:22.730: D/StateMachine(651): processMsg: ConnectedState
04-11 11:32:22.730: D/WifiStateMachine(651): ConnectedState{ what=131155 when=-5ms arg1=1121 }
04-11 11:32:22.730: D/StateMachine(651): processMsg: L2ConnectedState
04-11 11:32:22.740: D/WifiStateMachine(651): L2ConnectedState{ what=131155 when=-6ms arg1=1121 }
04-11 11:32:22.740: I/wpa_supplicant(17672): wlan0: Control interface command 'SIGNAL_POLL'
04-11 11:32:22.750: D/StateMachine(651): handleMessage: X

检查你的logcat信息你调试你的应用吗??是否等待了很长时间>如果在try块中抛出异常,则在logcat视图中检查堆栈跟踪。请参阅我更新的问题
04-11 11:32:09.206: D/StatusBar.NetworkController(1154): refreshViews: Data not connected!! Set no data type icon
04-11 11:32:09.206: D/StatusBar.NetworkController(1154): refreshViews connected={ wifi } level=4 combinedSignalIconId=0x7f0200c1/com.android.systemui:drawable/stat_sys_wifi_signal_4_fully combinedActivityIconId=0x7f0200b1 mobileLabel=BSNL MOBILE wifiLabel=LeewayxxxxXXXXxxxxXXXX emergencyOnly=false combinedLabel=LeewayxxxxXXXXxxxxXXXX mAirplaneMode=false mDataActivity=0 mPhoneSignalIconId=0x7f0200a7 mDataDirectionIconId=0x0 mDataSignalIconId=0x7f0200a7 mDataTypeIconId=0x0 mNoSimIconId=0x0 mWifiIconId=0x7f0200c1 mBluetoothTetherIconId=0x108076a
04-11 11:32:09.206: D/StatusBar.NetworkController(1154): changing data overlay icon id to 2130837681
04-11 11:32:10.657: D/StateMachine(651): handleMessage: E msg.what=131155
04-11 11:32:10.657: D/StateMachine(651): processMsg: ConnectedState
04-11 11:32:10.657: D/WifiStateMachine(651): ConnectedState{ what=131155 when=-6ms arg1=1121 }
04-11 11:32:10.657: D/StateMachine(651): processMsg: L2ConnectedState
04-11 11:32:10.657: D/WifiStateMachine(651): L2ConnectedState{ what=131155 when=-9ms arg1=1121 }
04-11 11:32:10.657: I/wpa_supplicant(17672): wlan0: Control interface command 'SIGNAL_POLL'
04-11 11:32:10.667: D/StateMachine(651): handleMessage: X
04-11 11:32:11.208: W/SignalStrength(1154): getLTELevel - rsrp:2147483647 snr:2147483647 rsrpIconLevel:-1 snrIconLevel:-1
04-11 11:32:11.208: W/SignalStrength(1154): getLTELevel - rssi:99 rssiIconLevel:0
04-11 11:32:11.208: W/SignalStrength(1154): getTdScdmaLevel = 0
04-11 11:32:11.208: W/SignalStrength(1154): getGsmLevel=4
04-11 11:32:11.208: W/SignalStrength(1154): getLevel=4
04-11 11:32:11.208: D/StatusBar.NetworkController(1154): refreshViews: Data not connected!! Set no data type icon
04-11 11:32:11.208: D/StatusBar.NetworkController(1154): refreshViews connected={ wifi } level=4 combinedSignalIconId=0x7f0200c1/com.android.systemui:drawable/stat_sys_wifi_signal_4_fully combinedActivityIconId=0x0 mobileLabel=BSNL MOBILE wifiLabel=LeewayxxxxXXXXxxxxXXXX emergencyOnly=false combinedLabel=LeewayxxxxXXXXxxxxXXXX mAirplaneMode=false mDataActivity=0 mPhoneSignalIconId=0x7f0200a7 mDataDirectionIconId=0x0 mDataSignalIconId=0x7f0200a7 mDataTypeIconId=0x0 mNoSimIconId=0x0 mWifiIconId=0x7f0200c1 mBluetoothTetherIconId=0x108076a
04-11 11:32:11.218: D/StatusBar.NetworkController(1154): changing data overlay icon id to 0
04-11 11:32:13.681: D/StateMachine(651): handleMessage: E msg.what=131155
04-11 11:32:13.681: D/StateMachine(651): processMsg: ConnectedState
04-11 11:32:13.681: D/WifiStateMachine(651): ConnectedState{ what=131155 when=-3ms arg1=1121 }
04-11 11:32:13.681: D/StateMachine(651): processMsg: L2ConnectedState
04-11 11:32:13.681: D/WifiStateMachine(651): L2ConnectedState{ what=131155 when=-6ms arg1=1121 }
04-11 11:32:13.681: I/wpa_supplicant(17672): wlan0: Control interface command 'SIGNAL_POLL'
04-11 11:32:13.691: D/StateMachine(651): handleMessage: X
04-11 11:32:16.694: D/StateMachine(651): handleMessage: E msg.what=131155
04-11 11:32:16.694: D/StateMachine(651): processMsg: ConnectedState
04-11 11:32:16.694: D/WifiStateMachine(651): ConnectedState{ what=131155 when=-5ms arg1=1121 }
04-11 11:32:16.694: D/StateMachine(651): processMsg: L2ConnectedState
04-11 11:32:16.694: D/WifiStateMachine(651): L2ConnectedState{ what=131155 when=-7ms arg1=1121 }
04-11 11:32:16.694: I/wpa_supplicant(17672): wlan0: Control interface command 'SIGNAL_POLL'
04-11 11:32:16.714: D/StateMachine(651): handleMessage: X
04-11 11:32:19.707: D/StateMachine(651): handleMessage: E msg.what=131155
04-11 11:32:19.707: D/StateMachine(651): processMsg: ConnectedState
04-11 11:32:19.707: D/WifiStateMachine(651): ConnectedState{ what=131155 when=-4ms arg1=1121 }
04-11 11:32:19.717: D/StateMachine(651): processMsg: L2ConnectedState
04-11 11:32:19.717: D/WifiStateMachine(651): L2ConnectedState{ what=131155 when=-6ms arg1=1121 }
04-11 11:32:19.717: I/wpa_supplicant(17672): wlan0: Control interface command 'SIGNAL_POLL'
04-11 11:32:19.727: D/StateMachine(651): handleMessage: X
04-11 11:32:22.730: D/StateMachine(651): handleMessage: E msg.what=131155
04-11 11:32:22.730: D/StateMachine(651): processMsg: ConnectedState
04-11 11:32:22.730: D/WifiStateMachine(651): ConnectedState{ what=131155 when=-5ms arg1=1121 }
04-11 11:32:22.730: D/StateMachine(651): processMsg: L2ConnectedState
04-11 11:32:22.740: D/WifiStateMachine(651): L2ConnectedState{ what=131155 when=-6ms arg1=1121 }
04-11 11:32:22.740: I/wpa_supplicant(17672): wlan0: Control interface command 'SIGNAL_POLL'
04-11 11:32:22.750: D/StateMachine(651): handleMessage: X
HttpURLConnection connection = null;
    try {
        URL u = new URL("http://www.google.com/");
        connection = (HttpURLConnection) u.openConnection();
        connection.setRequestMethod("HEAD");
        int code = connection.getResponseCode();
        System.out.println("" + code);
        // You can determine on HTTP return code received. 200 is success.
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        if (connection != null) {
            connection.disconnect();
        }
    }