<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>josecgomez.com &#187; Tutorials</title>
	<atom:link href="http://www.josecgomez.com/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.josecgomez.com</link>
	<description>The random thoughts of an IT professional.</description>
	<lastBuildDate>Wed, 18 Jan 2012 13:40:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Sleeping Sort (the algorithm)</title>
		<link>http://www.josecgomez.com/2011/07/19/sleeping-sorting-algorithm/</link>
		<comments>http://www.josecgomez.com/2011/07/19/sleeping-sorting-algorithm/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 14:56:28 +0000</pubDate>
		<dc:creator>Jose C Gomez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Views]]></category>
		<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Sorting]]></category>

		<guid isPermaLink="false">http://www.josecgomez.com/?p=685</guid>
		<description><![CDATA[Credit where credit is due, I ran across this elsewhere a while ago and figured i&#8217;d give it a shot in C#, sadly I don&#8217;t remember where I saw  it, but either way I present to you a new awesome sorting algorithm. If all the stars align and your list is short enough this will sort properly! [...]]]></description>
			<content:encoded><![CDATA[<p>Credit where credit is due, I ran across this elsewhere a while ago and figured i&#8217;d give it a shot in C#, sadly I don&#8217;t remember where I saw  it, but either way I present to you a new awesome sorting algorithm.</p>
<pre class="brush: csharp; title: ; notranslate">
private static void Sort(List&lt;int&gt; integers)
        {
            foreach (int i in integers)
            {
                Thread t = new Thread(new ParameterizedThreadStart(display));
                t.Start(i);
            }
        }

        private static void display(object x)
        {
            int i = (int)x;
            Thread.Sleep(i * 100);
            Console.WriteLine(i);
        }
</pre>
<p>If all the stars align and your list is short enough this will sort properly!</p>
<p>*SHEERS*</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.josecgomez.com/2011/07/19/sleeping-sorting-algorithm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Instead of Insert Trigger</title>
		<link>http://www.josecgomez.com/2010/05/11/instead-of-insert-trigger/</link>
		<comments>http://www.josecgomez.com/2010/05/11/instead-of-insert-trigger/#comments</comments>
		<pubDate>Tue, 11 May 2010 14:16:03 +0000</pubDate>
		<dc:creator>Jose C Gomez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[triggers]]></category>

		<guid isPermaLink="false">http://www.josecgomez.com/?p=501</guid>
		<description><![CDATA[Ever wanted to have an easy way to get the most recent entry for any given key on a massive database? I ran into this problem a few days ago at work and I wanted to attempt to explain how I solved it. We have a large database that contains the lifetime history of our [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to have an easy way to get the most recent entry for any given key on a massive database? I ran into this problem a few days ago at work and I wanted to attempt to explain how I solved it.</p>
<p>We have a large database that contains the lifetime history of our trucks GPS locations. The data in these tables is entered once every 10 seconds per truck, given the fact that we have about 30 trucks on average there are about 31536000 entries into this table per year and we have been running this program for several years now. We need a quick way to get the most recent location for every truck on the fleet regardless of whether it was last reported 10 seconds ago or 10 days ago.</p>
<p>For a while we had created a simple SQL query that returned the MAX(date) record for each given truck and this seemed to work all right. That is until yesterday evening, at that time the query that I just mentioned was taking somewhere in the realm of 10-15 minutes to execute, just long enough for our program to time out. Our table now contains somewhere in the realm of two billion records and this query is just not efficient enough. We attempted to optimize the query and gained some performance but not nearly enough to make a sustainable difference in the future.</p>
<p>The program that relies on this query is a real time monitoring system and we cannot sit there and wait for this to process during several minutes. An idea I had was to intercept the incoming stream and tag it as &#8220;most-recent&#8221; before insertion thus allowing a simple query such as &#8220;SELECT * FROM TABLE WHERE MOST-RECENT=true&#8221; would work. The challenge with this approach was, the interception of the data. We knew that we could write a simple database trigger, but had no idea if  would allow us to modify the incoming data stream.</p>
<p>Most of the database triggers happen after insertion, or update so this may have posed a problem. However it appears that Microsoft had thought about this for us and gave us &#8220;Instead of Insert&#8221; triggers. This triggers take the incoming data and allow you to do something with it other than actually inserting it into the database. We decided to take the incoming data, update the table to clear the &#8220;most-current&#8221; flag and then insert the data while updating the current records most-current flag. See the implementation below, we went from a 10 minute query to a milliseconds long query. And the overhead placed on the insert hasn&#8217;t posed a problem for the amount of data we receive.</p>
<pre class="brush: sql; title: ; notranslate">
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Jose C Gomez
-- Create date: 5/10/2010
-- Description:	Trigger that allows us to keep track of the Vehicles most recent location
-- =============================================
CREATE TRIGGER InsteadofInsert
   ON  dbo.current_location
   INSTEAD OF INSERT
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
--CLEAR THE OLDER MOST-RECENT FLAG
UPDATE current_location
SET most_current=0
WHERE most_current =1 AND  Device_ID in (SELECT Device_ID from Inserted);

--INSERT THE RECORD WITH THE MOST-RECENT FLAF SET TO TRUE (1)
INSERT INTO current_location
	SELECT Device_ID, Lat, Lon, date, ip_address, direction, speed ,1
	FROM Inserted

END
GO
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.josecgomez.com/2010/05/11/instead-of-insert-trigger/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Android Putting Custom Objects in ListView</title>
		<link>http://www.josecgomez.com/2010/05/03/android-putting-custom-objects-in-listview/</link>
		<comments>http://www.josecgomez.com/2010/05/03/android-putting-custom-objects-in-listview/#comments</comments>
		<pubDate>Mon, 03 May 2010 13:50:02 +0000</pubDate>
		<dc:creator>Jose C Gomez</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[ListView]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.josecgomez.com/?p=394</guid>
		<description><![CDATA[Following up to my last post, I would like to show you in detail how to get our custom List to be shown in a ListView follow along. The first thing we need to do is create out layout files, I have for this example created two layout files, one called main and one called [...]]]></description>
			<content:encoded><![CDATA[<p>Following up to my last post, I would like to show you in detail how to get our custom List to be shown in a ListView follow along.</p>
<p>The first thing we need to do is create out layout files, I have for this example created two layout files, one called main and one called listitems the code is below.</p>
<p>main.xml</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    &gt;
&lt;ListView
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    android:id=&quot;@+id/lstText&quot;
    /&gt;
&lt;/LinearLayout&gt;
</pre>
<p>listitems.xml</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
	android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot;&gt;
	&lt;LinearLayout
	android:orientation=&quot;vertical&quot;
	android:layout_width=&quot;0dip&quot; android:layout_weight=&quot;1&quot;
	android:layout_height=&quot;fill_parent&quot;&gt;
		&lt;TextView
		android:layout_width=&quot;fill_parent&quot;
		android:layout_height=&quot;wrap_content&quot;
		android:id=&quot;@+id/txtAlertText&quot; /&gt;
		&lt;TextView
		android:layout_width=&quot;fill_parent&quot;
		android:layout_height=&quot;wrap_content&quot;
		android:id=&quot;@+id/txtAlertDate&quot; /&gt;
	&lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</pre>
<p>Once you&#8217;ve done this you need to create an new ArrayAdapter class specific to your object as such</p>
<pre class="brush: java; title: ; notranslate">
package josecgomez.com.android.dev.webservice;

import java.util.List;

import josecgomez.com.android.dev.webservice.objects.alerts;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class AlertsAdapter extends ArrayAdapter&lt;alerts&gt; {

	int resource;
	String response;
	Context context;
	//Initialize adapter
	public AlertsAdapter(Context context, int resource, List&lt;alerts&gt; items) {
		super(context, resource, items);
		this.resource=resource;

	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		LinearLayout alertView;
		//Get the current alert object
		alerts al = getItem(position);

		//Inflate the view
		if(convertView==null)
		{
			alertView = new LinearLayout(getContext());
			String inflater = Context.LAYOUT_INFLATER_SERVICE;
			LayoutInflater vi;
			vi = (LayoutInflater)getContext().getSystemService(inflater);
			vi.inflate(resource, alertView, true);
		}
		else
		{
			alertView = (LinearLayout) convertView;
		}
		//Get the text boxes from the listitem.xml file
		TextView alertText =(TextView)alertView.findViewById(R.id.txtAlertText);
		TextView alertDate =(TextView)alertView.findViewById(R.id.txtAlertDate);

		//Assign the appropriate data from our alert object above
		alertText.setText(al.alerttext);
		alertDate.setText(al.alertdate);

		return alertView;
	}

}
</pre>
<p>Then on your main activity you may add this items to the list as shown below. Please keep in mind that this tutorial assumes you&#8217;ve correctly implemented my web service calls in a previous post.</p>
<pre class="brush: java; title: ; notranslate">
package josecgomez.com.android.dev.webservice;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import josecgomez.com.android.dev.webservice.objects.alerts;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class main extends Activity {
    /** Called when the activity is first created. */
	//ListView that will hold our items references back to main.xml
	ListView lstTest;
	//Array Adapter that will hold our ArrayList and display the items on the ListView
	AlertsAdapter arrayAdapter;

	//List that will  host our items and allow us to modify that array adapter
	ArrayList&lt;alerts&gt; alrts=null;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        //Initialize ListView
        lstTest= (ListView)findViewById(R.id.lstText);

         //Initialize our ArrayList
        alrts = new ArrayList&lt;alerts&gt;();
        //Initialize our array adapter notice how it references the listitems.xml layout
        arrayAdapter = new AlertsAdapter(main.this, R.layout.listitems,alrts);

        //Set the above adapter as the adapter of choice for our list
        lstTest.setAdapter(arrayAdapter);

        //Instantiate the Web Service Class with he URL of the web service not that you must pass
        WebService webService = new WebService(&quot;http://www.sumasoftware.com/alerts/GetAlerts.php&quot;);

        //Pass the parameters if needed , if not then pass dummy one as follows
		Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
		params.put(&quot;var&quot;, &quot;&quot;);

		//Get JSON response from server the &quot;&quot; are where the method name would normally go if needed example
		// webService.webGet(&quot;getMoreAllerts&quot;, params);
		String response = webService.webGet(&quot;&quot;, params);

		try
		{
			//Parse Response into our object
			Type collectionType = new TypeToken&lt;ArrayList&lt;alerts&gt;&gt;(){}.getType();

			//JSON expects an list so can't use our ArrayList from the lstart
			List&lt;alerts&gt; lst= new Gson().fromJson(response, collectionType);

			//Now that we have that list lets add it to the ArrayList which will hold our items.
			for(alerts l : lst)
			{
				alrts.add(l);
			}

			//Since we've modified the arrayList we now need to notify the adapter that
			//its data has changed so that it updates the UI
			arrayAdapter.notifyDataSetChanged();
		}
		catch(Exception e)
		{
			Log.d(&quot;Error: &quot;, e.getMessage());
		}
    }
}
 </pre>
<p>I hope this helps</p>
<p><a href="http://www.josecgomez.com/wordpress/wp-content/uploads/2010/05/emulator.png"><img src="http://www.josecgomez.com/wordpress/wp-content/uploads/2010/05/emulator-300x212.png" alt="" title="emulator" width="300" height="212" class="aligncenter size-medium wp-image-422" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.josecgomez.com/2010/05/03/android-putting-custom-objects-in-listview/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>Android accessing RESTFull Web Services using JSON</title>
		<link>http://www.josecgomez.com/2010/04/30/android-accessing-restfull-web-services-using-json/</link>
		<comments>http://www.josecgomez.com/2010/04/30/android-accessing-restfull-web-services-using-json/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 13:31:05 +0000</pubDate>
		<dc:creator>Jose C Gomez</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Gson]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.josecgomez.com/?p=379</guid>
		<description><![CDATA[I just finished a huge project for school using the Google Android OS. The biggest hurdle I had to jump through we getting android to successfully talk to web services. I have put together a set of classes and procedures to do so that make it easy and reliable. I have taken some code from [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished a huge project for school using the Google Android OS. The biggest hurdle I had to jump through we getting android to successfully talk to web services. I have put together a set of classes and procedures to do so that make it easy and reliable. I have taken some code from here and there and adapted my own. It was a while ago so I don&#8217;t recall where I found it all. For this example I am going to be using the web service  <a href="http://www.sumasoftware.com/alerts/GetAlerts.php">http://www.sumasoftware.com/alerts/GetAlerts.php</a> to read the alerts.</p>
<p>The first thing you&#8217;ll need to download and add to your project is the google GSON library <a href="http://code.google.com/p/google-gson/issues/list">http://code.google.com/p/google-gson/downloads/list</a></p>
<p><a href="http://code.google.com/p/google-gson/issues/list"></a>Add the jar file to your android project as an external jar</p>
<p>Download the following WebService.java class in order to interact with the web service and add it to your project</p>
<p>
<pre class="brush: java; title: ; notranslate">
package josecgomez.com.android.dev.webservice;

import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Map;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.params.ClientPNames;
import org.apache.http.client.params.CookiePolicy;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

import com.google.gson.Gson;

public class WebService{

    DefaultHttpClient httpClient;
    HttpContext localContext;
    private String ret;

    HttpResponse response = null;
    HttpPost httpPost = null;
    HttpGet httpGet = null;
    String webServiceUrl;

    //The serviceName should be the name of the Service you are going to be using.
    public WebService(String serviceName){
        HttpParams myParams = new BasicHttpParams();

        HttpConnectionParams.setConnectionTimeout(myParams, 10000);
        HttpConnectionParams.setSoTimeout(myParams, 10000);
        httpClient = new DefaultHttpClient(myParams);
        localContext = new BasicHttpContext();
        webServiceUrl = serviceName;

    }

    //Use this method to do a HttpPost\WebInvoke on a Web Service
    public String webInvoke(String methodName, Map&lt;String, Object&gt; params) {

    	JSONObject jsonObject = new JSONObject();

    	for (Map.Entry&lt;String, Object&gt; param : params.entrySet()){
    		try {
    			jsonObject.put(param.getKey(), param.getValue());
			}
    		catch (JSONException e) {
    			Log.e(&quot;Groshie&quot;, &quot;JSONException : &quot;+e);
			}
    	}
        return webInvoke(methodName,  jsonObject.toString(), &quot;application/json&quot;);
    }

    private String webInvoke(String methodName, String data, String contentType) {
        ret = null;

        httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.RFC_2109);

        httpPost = new HttpPost(webServiceUrl + methodName);
        response = null;

        StringEntity tmp = null;        

        //httpPost.setHeader(&quot;User-Agent&quot;, &quot;SET YOUR USER AGENT STRING HERE&quot;);
        httpPost.setHeader(&quot;Accept&quot;,
&quot;text/html,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5&quot;);

        if (contentType != null) {
            httpPost.setHeader(&quot;Content-Type&quot;, contentType);
        } else {
            httpPost.setHeader(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot;);
        }

        try {
            tmp = new StringEntity(data,&quot;UTF-8&quot;);
        } catch (UnsupportedEncodingException e) {
            Log.e(&quot;Groshie&quot;, &quot;HttpUtils : UnsupportedEncodingException : &quot;+e);
        }

        httpPost.setEntity(tmp);

        Log.d(&quot;Groshie&quot;, webServiceUrl + &quot;?&quot; + data);

        try {
            response = httpClient.execute(httpPost,localContext);

            if (response != null) {
                ret = EntityUtils.toString(response.getEntity());
            }
        } catch (Exception e) {
            Log.e(&quot;Groshie&quot;, &quot;HttpUtils: &quot; + e);
        }

        return ret;
    }

    //Use this method to do a HttpGet/WebGet on the web service
    public String webGet(String methodName, Map&lt;String, String&gt; params) {
    	String getUrl = webServiceUrl + methodName;

    	int i = 0;
    	for (Map.Entry&lt;String, String&gt; param : params.entrySet())
    	{
    		if(i == 0){
    			getUrl += &quot;?&quot;;
    		}
    		else{
    			getUrl += &quot;&amp;&quot;;
    		}

    		try {
				getUrl += param.getKey() + &quot;=&quot; + URLEncoder.encode(param.getValue(),&quot;UTF-8&quot;);
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

    		i++;
    	}

        httpGet = new HttpGet(getUrl);
        Log.e(&quot;WebGetURL: &quot;,getUrl);

        try {
            response = httpClient.execute(httpGet);
        } catch (Exception e) {
            Log.e(&quot;Groshie:&quot;, e.getMessage());
        }

        // we assume that the response body contains the error message
        try {
            ret = EntityUtils.toString(response.getEntity());
        } catch (IOException e) {
            Log.e(&quot;Groshie:&quot;, e.getMessage());
        }

        return ret;
    }

    public static JSONObject Object(Object o){
    	try {
			return new JSONObject(new Gson().toJson(o));
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return null;
    }

    public InputStream getHttpStream(String urlString) throws IOException {
        InputStream in = null;
        int response = -1;

        URL url = new URL(urlString);
        URLConnection conn = url.openConnection();

        if (!(conn instanceof HttpURLConnection))
            throw new IOException(&quot;Not an HTTP connection&quot;);

        try{
            HttpURLConnection httpConn = (HttpURLConnection) conn;
            httpConn.setAllowUserInteraction(false);
            httpConn.setInstanceFollowRedirects(true);
            httpConn.setRequestMethod(&quot;GET&quot;);
            httpConn.connect(); 

            response = httpConn.getResponseCode();                 

            if (response == HttpURLConnection.HTTP_OK) {
                in = httpConn.getInputStream();
            }
        } catch (Exception e) {
            throw new IOException(&quot;Error connecting&quot;);
        } // end try-catch

        return in;
    }

    public void clearCookies() {
        httpClient.getCookieStore().clear();
    }

    public void abort() {
        try {
            if (httpClient != null) {
                System.out.println(&quot;Abort.&quot;);
                httpPost.abort();
            }
        } catch (Exception e) {
            System.out.println(&quot;Your App Name Here&quot; + e);
        }
    }
}
</pre>
</p>
<p>Based on the structure of your JSON file develop a class in your project to support the structure. For example for the above mentioned service I developed this class. </p>
<p>The JSON returned has this structure {&#8220;alertid&#8221;:&#8221;1&#8243;,&#8221;alerttext&#8221;:&#8221;This is test&#8221;,&#8221;alertdate&#8221;:&#8221;2010-02-11 09:03:40&#8243;}</p>
<p>
<pre class="brush: java; title: ; notranslate">
package josecgomez.com.android.dev.webservice.objects;

public class alerts {

	public int alertid;
	public String alerttext;
	public String alertdate;

	@Override
	public String toString()
	{
		return &quot;Alert ID: &quot;+alertid+ &quot; Alert Text: &quot;+alerttext+ &quot; Alert Date: &quot;+alertdate;

	}
}
</pre>
<p>Once you&#8217;ve done this in your android activity you may execute the following code to access the web service</p>
<p>
<pre class="brush: java; title: ; notranslate">
 // Instantiate the Web Service Class with he URL of the web service not that you must pass

        WebService webService = new WebService(&quot;http://www.sumasoftware.com/alerts/GetAlerts.php&quot;);

        //Pass the parameters if needed , if not then pass dummy one as follows
		Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
		params.put(&quot;var&quot;, &quot;&quot;);

		//Get JSON response from server the &quot;&quot; are where the method name would normally go if needed example
		// webService.webGet(&quot;getMoreAllerts&quot;, params);
		String response = webService.webGet(&quot;&quot;, params);

		try
		{
			//Parse Response into our object
			Type collectionType = new TypeToken&lt;List&lt;alerts&gt;&gt;(){}.getType();
			List&lt;alerts&gt; alrt = new Gson().fromJson(response, collectionType);

		}
		catch(Exception e)
		{
			Log.d(&quot;Error: &quot;, e.getMessage());
		}
</pre>
</p>
<p>Please note that the above code is for accessing collection of items, if you are attempting to access a single item there should be a slight modification to the code as follows</p>
<p>
<pre class="brush: java; title: ; notranslate">
/* Replace
Type collectionType = new TypeToken&lt;List&lt;alerts&gt;&gt;(){}.getType();
List&lt;alerts&gt; alrt = new Gson().fromJson(response, collectionType);
with
*/
alerts alert = new Gson().fromJson(response, alerts.class);
</pre>
</p>
<p>The above method uses GET if you need to INVOKE POST there should be a slight modification to the above code as follows. I hope this helps.</p>
<p>
<pre class="brush: java; title: ; notranslate">
/* Replace
String response = webService.webGet(&quot;&quot;, params);
with
*/
webService.webInvoke(&quot;&quot;, params);
</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.josecgomez.com/2010/04/30/android-accessing-restfull-web-services-using-json/feed/</wfw:commentRss>
		<slash:comments>57</slash:comments>
		</item>
		<item>
		<title>Windows 7 Shake to Minimize?</title>
		<link>http://www.josecgomez.com/2009/06/08/windows-7-shake-to-minimize/</link>
		<comments>http://www.josecgomez.com/2009/06/08/windows-7-shake-to-minimize/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 13:24:48 +0000</pubDate>
		<dc:creator>Jose C Gomez</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[minimize]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[shake]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://www.josecgomez.com/?p=324</guid>
		<description><![CDATA[So I installed Windows 7 as my main OS at work a few days ago just to play around in a &#8220;Production Environment&#8221; and this morning I ran into the strangest, yet most useful feature yet. Apparently in an Aero enabled PC with Windows 7 if you grab and shake your foreground window it will [...]]]></description>
			<content:encoded><![CDATA[<p>So I installed Windows 7 as my main OS at work a few days ago just to play around in a &#8220;Production Environment&#8221; and this morning I ran into the strangest, yet most useful feature yet. Apparently in an Aero enabled PC with Windows 7 if you grab and shake your foreground window it will automatically minimize all the windows behind it, clearing all the noise. Once you are done, you can get all your windows back by shaking the screen again. Very useful! yet it can get annoying, I have several times now shaken my screen in anger or while waiting for something (who hasn&#8217;t?), and everything drops down. Check out the vid if you don&#8217;t believe me.</p>
<p style="text-align: center;">
<p><a href="http://www.youtube.com/watch?v=fEkSSaq-QFk">www.youtube.com/watch?v=fEkSSaq-QFk</a></p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.josecgomez.com/2009/06/08/windows-7-shake-to-minimize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Security by obscurity?</title>
		<link>http://www.josecgomez.com/2008/05/28/security-by-obscurity/</link>
		<comments>http://www.josecgomez.com/2008/05/28/security-by-obscurity/#comments</comments>
		<pubDate>Wed, 28 May 2008 20:26:36 +0000</pubDate>
		<dc:creator>Jose C Gomez</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.josecgomez.com/?p=20</guid>
		<description><![CDATA[One of the most annoying website you find when searching for a solution to a problem on Google is http:///www.experts-exchange.com some how someone already asked the same exact question you have. But unfortunately when you go to the page you get something like &#8220;Experts Comments are for Premium Members Only&#8221; Example http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23172666.html you know they have the answer, but [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most annoying website you find when searching for a solution to a problem on Google is <a href="http:///www.experts-exchange.com">http:///www.experts-exchange.com</a> some how someone already asked the same exact question you have. But unfortunately when you go to the page you get something like &#8220;Experts Comments are for Premium Members Only&#8221; Example <a href="http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23172666.html">http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23172666.html</a> you know they have the answer, but is it worth paying? Well they are using an absurd security by obscurity method to ensure you will pay for their services. See any regular Internet user that sees the &#8220;For Premium Members Only&#8221; sign will immediately hit the back button frustrated and continue on googling. But if you had a bit of curiosity you may find yourself with the answer you were looking for. What is the secret? SCROLL if you scroll down past all the warning and announcements you will find yourself in front of the answers you were seeking. Use it while you can because I am sure after this post hits the web they will promptly close their &#8220;Security Hole&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.josecgomez.com/2008/05/28/security-by-obscurity/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Photoshop Fire</title>
		<link>http://www.josecgomez.com/2008/05/23/photoshop-fire/</link>
		<comments>http://www.josecgomez.com/2008/05/23/photoshop-fire/#comments</comments>
		<pubDate>Fri, 23 May 2008 20:34:11 +0000</pubDate>
		<dc:creator>Jose C Gomez</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.josecgomez.com/?p=12</guid>
		<description><![CDATA[I came across this tutorial I wrote a while back. It creates a great Flaming Text effect using Photoshop Link Here. I will move it to this site as soon as I get a chance. Enjoy there for now]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-13" title="Flaming-Text" src="http://www.josecgomez.com/wordpress/wp-content/uploads/2008/05/flaming-300x139.jpg" alt="Flaming Text" width="300" height="139" /></p>
<p>I came across this tutorial I wrote a while back. It creates a great Flaming Text effect using Photoshop <a href="http://www.unf.edu/~gomj0001/cgs3559/final/" target="_blank">Link Here</a>. I will move it to this site as soon as I get a chance. Enjoy there for now <img src='http://www.josecgomez.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.josecgomez.com/2008/05/23/photoshop-fire/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

