/**
 * Copyright 2017 FreshPlanet
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.freshplanet.ane.AirPushNotification;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import android.os.AsyncTask;

public class PingUrlTask extends AsyncTask<String, Void, Boolean> {

	@Override
	protected Boolean doInBackground(String... urls) {
				
		String trackingUrl = urls[0];
		
		Extension.log("start tracking "+trackingUrl);

		
		HttpURLConnection connection = null;
		try {
			connection = (HttpURLConnection)(new URL(trackingUrl)).openConnection();
			connection.setDoInput(true);
			connection.connect();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return null;
	}
	
	@Override
	protected void onPostExecute(Boolean downloadSuccess)
	{
		Extension.log("tracking complete");
	}

}

@@ -788,16 +788,41 @@
 yncTask;
+%0Aimport android.util.Log;
 %0A%0Apublic
@@ -1042,60 +1042,61 @@
 %0A%0A%09%09
-%0A%09%09HttpURLConnection connection = null;%0A%09%09try %7B%0A%09%09%09c
+try %7B%0A%09%09%09URL url = new URL(trackingUrl);%0A%0A%09%09%09HttpURLC
 onne
@@ -1101,16 +1101,21 @@
 nection 
+urlc 
 = (HttpU
@@ -1131,206 +1131,252 @@
 ion)
-(new URL(trackingUrl)).openConnection();%0A%09%09%09connection.setDoInput(true);%0A%09%09%09connection.connect();%0A%09%09%7D catch (MalformedURLException e) %7B%0A%09%09%09// TODO Auto-generated catch block%0A%09%09%09e.printStackTrace
+ url.openConnection();%0A%09%09%09urlc.setRequestMethod(%22GET%22);%0A%09%09%09urlc.setRequestProperty(%22User-Agent%22, %22Android%22);%0A%09%09%09urlc.setRequestProperty(%22Connection%22, %22close%22);%0A%09%09%09urlc.setDoInput(true);%0A%09%09%09urlc.setConnectTimeout(1000 * 10);%0A%09%09%09urlc.connect
 ();%0A
+%0A
 %09%09%7D 
@@ -1382,18 +1382,28 @@
  catch (
-IO
+MalformedURL
 Exceptio
@@ -1409,54 +1409,18 @@
 on e
+1
 ) %7B%0A%09%09%09
-// TODO Auto-generated catch block%0A%09%09%09
 e
+1
 .pri
@@ -1446,16 +1446,18 @@
  catch (
+IO
 Exceptio
@@ -1621,14 +1621,15 @@
 lete%22);%0A
+%0A
 %09%7D%0A%0A%7D%0A

fix pingUrlTask