Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onCreate() {
- super.onCreate();
- try {
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- while (true) {
- sleep(2000);
- HttpURLConnection conn = null;
- InputStream is = null;
- try {
- System.setProperty("http.keepAlive", "false");
- URL url = new URL("http://example.com");
- conn = (HttpURLConnection)url.openConnection();
- is = new BufferedInputStream(conn.getInputStream());
- is.close();
- } catch (Exception ex) {
- } finally {
- if (conn != null) {
- conn.disconnect();
- }
- }
- }
- }catch (Exception e) {
- e.printStackTrace();
- } finally {
- }
- }
- };
- thread.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment