Search in sources :

Example 1 with InterruptedException

use of java.lang.InterruptedException in project android_frameworks_base by ResurrectionRemix.

the class CaptivePortalLoginActivity method onDestroy.

@Override
public void onDestroy() {
    super.onDestroy();
    if (mNetworkCallback != null) {
        mCm.unregisterNetworkCallback(mNetworkCallback);
        mNetworkCallback = null;
    }
    if (mLaunchBrowser) {
        // Give time for this network to become default. After 500ms just proceed.
        for (int i = 0; i < 5; i++) {
            // TODO: This misses when mNetwork underlies a VPN.
            if (mNetwork.equals(mCm.getActiveNetwork()))
                break;
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            }
        }
        final String url = mUrl.toString();
        if (DBG) {
            Log.d(TAG, "starting activity with intent ACTION_VIEW for " + url);
        }
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
    }
}
Also used : Intent(android.content.Intent) InterruptedException(java.lang.InterruptedException)

Example 2 with InterruptedException

use of java.lang.InterruptedException in project android_frameworks_base by DirtyUnicorns.

the class CaptivePortalLoginActivity method onDestroy.

@Override
public void onDestroy() {
    super.onDestroy();
    if (mNetworkCallback != null) {
        mCm.unregisterNetworkCallback(mNetworkCallback);
        mNetworkCallback = null;
    }
    if (mLaunchBrowser) {
        // Give time for this network to become default. After 500ms just proceed.
        for (int i = 0; i < 5; i++) {
            // TODO: This misses when mNetwork underlies a VPN.
            if (mNetwork.equals(mCm.getActiveNetwork()))
                break;
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            }
        }
        final String url = mUrl.toString();
        if (DBG) {
            Log.d(TAG, "starting activity with intent ACTION_VIEW for " + url);
        }
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
    }
}
Also used : Intent(android.content.Intent) InterruptedException(java.lang.InterruptedException)

Example 3 with InterruptedException

use of java.lang.InterruptedException in project platform_frameworks_base by android.

the class CaptivePortalLoginActivity method onDestroy.

@Override
public void onDestroy() {
    super.onDestroy();
    if (mNetworkCallback != null) {
        mCm.unregisterNetworkCallback(mNetworkCallback);
        mNetworkCallback = null;
    }
    if (mLaunchBrowser) {
        // Give time for this network to become default. After 500ms just proceed.
        for (int i = 0; i < 5; i++) {
            // TODO: This misses when mNetwork underlies a VPN.
            if (mNetwork.equals(mCm.getActiveNetwork()))
                break;
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            }
        }
        final String url = mUrl.toString();
        if (DBG) {
            Log.d(TAG, "starting activity with intent ACTION_VIEW for " + url);
        }
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
    }
}
Also used : Intent(android.content.Intent) InterruptedException(java.lang.InterruptedException)

Example 4 with InterruptedException

use of java.lang.InterruptedException in project wonderdog by infochimps-labs.

the class ElasticSearchStorage method getNext.

@Override
public Tuple getNext() throws IOException {
    try {
        Tuple tuple = TupleFactory.getInstance().newTuple(2);
        if (reader.nextKeyValue()) {
            Text docId = (Text) reader.getCurrentKey();
            Text docContent = (Text) reader.getCurrentValue();
            tuple.set(0, new DataByteArray(docId.toString()));
            tuple.set(1, new DataByteArray(docContent.toString()));
            return tuple;
        }
    } catch (InterruptedException e) {
        throw new IOException(e);
    }
    return null;
}
Also used : IOException(java.io.IOException) DataByteArray(org.apache.pig.data.DataByteArray) InterruptedException(java.lang.InterruptedException) Tuple(org.apache.pig.data.Tuple)

Example 5 with InterruptedException

use of java.lang.InterruptedException in project platform_frameworks_base by android.

the class CaptivePortalLoginActivity method testForCaptivePortal.

private void testForCaptivePortal() {
    // TODO: reuse NetworkMonitor facilities for consistent captive portal detection.
    new Thread(new Runnable() {

        public void run() {
            // Give time for captive portal to open.
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }
            HttpURLConnection urlConnection = null;
            int httpResponseCode = 500;
            try {
                urlConnection = (HttpURLConnection) mNetwork.openConnection(mUrl);
                urlConnection.setInstanceFollowRedirects(false);
                urlConnection.setConnectTimeout(SOCKET_TIMEOUT_MS);
                urlConnection.setReadTimeout(SOCKET_TIMEOUT_MS);
                urlConnection.setUseCaches(false);
                if (mUserAgent != null) {
                    urlConnection.setRequestProperty("User-Agent", mUserAgent);
                }
                // cannot read request header after connection
                String requestHeader = urlConnection.getRequestProperties().toString();
                urlConnection.getInputStream();
                httpResponseCode = urlConnection.getResponseCode();
                if (DBG) {
                    Log.d(TAG, "probe at " + mUrl + " ret=" + httpResponseCode + " request=" + requestHeader + " headers=" + urlConnection.getHeaderFields());
                }
            } catch (IOException e) {
            } finally {
                if (urlConnection != null)
                    urlConnection.disconnect();
            }
            if (httpResponseCode == 204) {
                done(Result.DISMISSED);
            }
        }
    }).start();
}
Also used : HttpURLConnection(java.net.HttpURLConnection) IOException(java.io.IOException) InterruptedException(java.lang.InterruptedException)

Aggregations

InterruptedException (java.lang.InterruptedException)12 IOException (java.io.IOException)7 Intent (android.content.Intent)5 HttpURLConnection (java.net.HttpURLConnection)5 Properties (java.util.Properties)1 DataByteArray (org.apache.pig.data.DataByteArray)1 Tuple (org.apache.pig.data.Tuple)1 UDFContext (org.apache.pig.impl.util.UDFContext)1 JsonParseException (org.codehaus.jackson.JsonParseException)1 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)1