<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: JavaME JSR-179 Example Code : Detect Location via TinyGeocoder</title>
	<atom:link href="http://mobilepit.com/02/javame-jsr-179-example-code-detect-location-via-tinygeocoder.html/feed" rel="self" type="application/rss+xml" />
	<link>http://mobilepit.com/02/javame-jsr-179-example-code-detect-location-via-tinygeocoder.html</link>
	<description>Mobile Phone, PDA and JavaME (J2ME) Programming Blog</description>
	<lastBuildDate>Wed, 28 Jul 2010 16:19:51 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: raj</title>
		<link>http://mobilepit.com/02/javame-jsr-179-example-code-detect-location-via-tinygeocoder.html/comment-page-1#comment-14886</link>
		<dc:creator>raj</dc:creator>
		<pubDate>Mon, 14 Jun 2010 07:32:43 +0000</pubDate>
		<guid isPermaLink="false">http://mobilepit.com/?p=142#comment-14886</guid>
		<description>Hi,

Is it possible to also display with maps (Google Maps, etc) which are representing the location on a J2ME application? If so, how?</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Is it possible to also display with maps (Google Maps, etc) which are representing the location on a J2ME application? If so, how?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: harryteguh</title>
		<link>http://mobilepit.com/02/javame-jsr-179-example-code-detect-location-via-tinygeocoder.html/comment-page-1#comment-14822</link>
		<dc:creator>harryteguh</dc:creator>
		<pubDate>Wed, 02 Dec 2009 08:13:39 +0000</pubDate>
		<guid isPermaLink="false">http://mobilepit.com/?p=142#comment-14822</guid>
		<description>Hi, there.

I tried some of the method from your project in my own Midlet. But I encountered a problem. The &quot;Location&quot; StringItem won&#039;t return me the coordinate&#039;s place name. Instead it gives me an error that reads &quot;602: Address cannot be found&quot;. Please help....

here&#039;s the full code:

/*
 * To change this template, choose Tools &#124; Templates
 * and open the template in the editor.
 */


import java.util.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.location.*;
import java.io.*;
import javax.microedition.io.*;

/**
 * @author Onime no Nero
 */
public class LocationMidletPhase1 extends MIDlet implements CommandListener{
    private Command exit=new Command(&quot;Exit&quot;, Command.EXIT,1);
    private Command location=new Command(&quot;Location&quot;, Command.ITEM,1);
        private Command minimize=new Command(&quot;Minimize&quot;, Command.ITEM,1);
    private String sUrl;
    private StringItem locationName = new StringItem(&quot;Location&quot;, &quot;&quot;);
    private Display display;
    private Form mainForm=new Form(&quot;NeroNull: Location Midlet&quot;);
    private StringItem lat=new StringItem(&quot;Latitude: &quot;, &quot;&quot;, Item.PLAIN);
    private StringItem lon=new StringItem(&quot;Longitude: &quot;,&quot;&quot;,Item.PLAIN);
    private StringItem alt=new StringItem(&quot;Altitude: &quot;,&quot;&quot;,Item.PLAIN);
    private StringItem speed=new StringItem(&quot;Speed: &quot;,&quot;&quot;,Item.PLAIN);
    private StringItem stat=new StringItem(&quot;Status: &quot;,&quot;&quot;,Item.PLAIN);
    private StringItem version=new StringItem(&quot;Version: &quot;,&quot;Unknown&quot;, Item.PLAIN);
    private LocationProvider provider;
      private Timer timer; 
  private ScheduledTransmission task; 
    private long startTime;
    public LocationMidletPhase1(){
        mainForm.addCommand(exit);
         mainForm.addCommand(location);
         mainForm.setCommandListener(this);
         version.setText(System.getProperty(&quot;microedition.location.version&quot;));
         startTime=System.currentTimeMillis();
         mainForm.append(version);
         mainForm.append(lat);
         mainForm.append(lon);
         mainForm.append(alt);
         mainForm.append(speed);
         mainForm.append(stat);
         mainForm.append(locationName);
    }
    
    public void startApp() {
        display=Display.getDisplay(this);
     

        display.setCurrent(mainForm);
        
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
    public void commandAction(Command c, Displayable d){
        if(c==location){
        new Thread();
            timer = new Timer();
    task = new ScheduledTransmission();
    timer.schedule(task,10,10000);
        }
        if(c==exit){
            destroyApp(true);
            notifyDestroyed();
            return;
        }
        if(c==minimize){
                        display.setCurrent(null);

        }
    }
    

       
     private class ScheduledTransmission extends TimerTask{
    public final void run(){
 try{
            Criteria cr=new Criteria();
            cr.setHorizontalAccuracy(0);
            cr.setVerticalAccuracy(0);
            
            provider=LocationProvider.getInstance(cr);
            long time=System.currentTimeMillis();
            Location loc=provider.getLocation(30);
            Coordinates coord=loc.getQualifiedCoordinates();
            if(coord!=null){
                if(loc.isValid()){
                       try {
testGET(sUrl);
} catch (IOException e) {
System.out.println(&quot;IOException &quot; + e);
e.printStackTrace();
}
                    lat.setText(Double.toString(coord.getLatitude()));
                    lon.setText(Double.toString(coord.getLongitude()));
                    alt.setText(Float.toString(coord.getAltitude()));
                    speed.setText(Float.toString(loc.getSpeed()));
                    stat.setText(&quot;Valid Location Information&quot;);
                             mainForm.append(locationName);

                   }
                else{
                    stat.setText(&quot;Invalid Location Information&quot;);
                }
            }
        }
        catch(LocationException e){
            stat.setText(&quot;Exception: &quot;+e.getMessage());
            
        }
        catch(InterruptedException e){
            stat.setText(&quot;Timeout: &quot;+e.getMessage());
        }
    
    }
  }
     void testGET(String sUrl) throws IOException {
         sUrl =&quot;http://tinygeocoder.com/create-api.php?g=&quot;+lat+&quot;,&quot;+lon;
HttpConnection connection = null;
InputStream is = null;
 String sb = null;

try {
connection = (HttpConnection)Connector.open(sUrl);
connection.setRequestMethod(HttpConnection.GET);
is = connection.openInputStream();
byte buf[] = new byte[128];
                    int total =0;
                    while (total &lt;128) {
                        int count = is.read(buf,total,128-total);
                        if (count&lt;0) {
                            break;
                        }
                        total += count;
                    }
    sb=new String(buf,0,total);
  if (sb.length() =0x30 &amp;&amp; b=0x41 &amp;&amp; b=0x61 &amp;&amp; b&lt;=0x7A)) {
                        tmp.append((char)b);
                    }
                    else {
                        tmp.append(&quot;%&quot;);
                        if (b &lt;= 0xf) tmp.append(&quot;0&quot;);
                        tmp.append(Integer.toHexString(b));
                    }
                }
            }
            catch (Exception e) {}
            return tmp.toString();
        }
        return null;
}
}</description>
		<content:encoded><![CDATA[<p>Hi, there.</p>
<p>I tried some of the method from your project in my own Midlet. But I encountered a problem. The &#8220;Location&#8221; StringItem won&#8217;t return me the coordinate&#8217;s place name. Instead it gives me an error that reads &#8220;602: Address cannot be found&#8221;. Please help&#8230;.</p>
<p>here&#8217;s the full code:</p>
<p>/*<br />
 * To change this template, choose Tools | Templates<br />
 * and open the template in the editor.<br />
 */</p>
<p>import java.util.*;<br />
import javax.microedition.midlet.*;<br />
import javax.microedition.lcdui.*;<br />
import javax.microedition.location.*;<br />
import java.io.*;<br />
import javax.microedition.io.*;</p>
<p>/**<br />
 * @author Onime no Nero<br />
 */<br />
public class LocationMidletPhase1 extends MIDlet implements CommandListener{<br />
    private Command exit=new Command(&#8221;Exit&#8221;, Command.EXIT,1);<br />
    private Command location=new Command(&#8221;Location&#8221;, Command.ITEM,1);<br />
        private Command minimize=new Command(&#8221;Minimize&#8221;, Command.ITEM,1);<br />
    private String sUrl;<br />
    private StringItem locationName = new StringItem(&#8221;Location&#8221;, &#8220;&#8221;);<br />
    private Display display;<br />
    private Form mainForm=new Form(&#8221;NeroNull: Location Midlet&#8221;);<br />
    private StringItem lat=new StringItem(&#8221;Latitude: &#8220;, &#8220;&#8221;, Item.PLAIN);<br />
    private StringItem lon=new StringItem(&#8221;Longitude: &#8220;,&#8221;",Item.PLAIN);<br />
    private StringItem alt=new StringItem(&#8221;Altitude: &#8220;,&#8221;",Item.PLAIN);<br />
    private StringItem speed=new StringItem(&#8221;Speed: &#8220;,&#8221;",Item.PLAIN);<br />
    private StringItem stat=new StringItem(&#8221;Status: &#8220;,&#8221;",Item.PLAIN);<br />
    private StringItem version=new StringItem(&#8221;Version: &#8220;,&#8221;Unknown&#8221;, Item.PLAIN);<br />
    private LocationProvider provider;<br />
      private Timer timer;<br />
  private ScheduledTransmission task;<br />
    private long startTime;<br />
    public LocationMidletPhase1(){<br />
        mainForm.addCommand(exit);<br />
         mainForm.addCommand(location);<br />
         mainForm.setCommandListener(this);<br />
         version.setText(System.getProperty(&#8221;microedition.location.version&#8221;));<br />
         startTime=System.currentTimeMillis();<br />
         mainForm.append(version);<br />
         mainForm.append(lat);<br />
         mainForm.append(lon);<br />
         mainForm.append(alt);<br />
         mainForm.append(speed);<br />
         mainForm.append(stat);<br />
         mainForm.append(locationName);<br />
    }</p>
<p>    public void startApp() {<br />
        display=Display.getDisplay(this);</p>
<p>        display.setCurrent(mainForm);</p>
<p>    }</p>
<p>    public void pauseApp() {<br />
    }</p>
<p>    public void destroyApp(boolean unconditional) {<br />
    }<br />
    public void commandAction(Command c, Displayable d){<br />
        if(c==location){<br />
        new Thread();<br />
            timer = new Timer();<br />
    task = new ScheduledTransmission();<br />
    timer.schedule(task,10,10000);<br />
        }<br />
        if(c==exit){<br />
            destroyApp(true);<br />
            notifyDestroyed();<br />
            return;<br />
        }<br />
        if(c==minimize){<br />
                        display.setCurrent(null);</p>
<p>        }<br />
    }</p>
<p>     private class ScheduledTransmission extends TimerTask{<br />
    public final void run(){<br />
 try{<br />
            Criteria cr=new Criteria();<br />
            cr.setHorizontalAccuracy(0);<br />
            cr.setVerticalAccuracy(0);</p>
<p>            provider=LocationProvider.getInstance(cr);<br />
            long time=System.currentTimeMillis();<br />
            Location loc=provider.getLocation(30);<br />
            Coordinates coord=loc.getQualifiedCoordinates();<br />
            if(coord!=null){<br />
                if(loc.isValid()){<br />
                       try {<br />
testGET(sUrl);<br />
} catch (IOException e) {<br />
System.out.println(&#8221;IOException &#8221; + e);<br />
e.printStackTrace();<br />
}<br />
                    lat.setText(Double.toString(coord.getLatitude()));<br />
                    lon.setText(Double.toString(coord.getLongitude()));<br />
                    alt.setText(Float.toString(coord.getAltitude()));<br />
                    speed.setText(Float.toString(loc.getSpeed()));<br />
                    stat.setText(&#8221;Valid Location Information&#8221;);<br />
                             mainForm.append(locationName);</p>
<p>                   }<br />
                else{<br />
                    stat.setText(&#8221;Invalid Location Information&#8221;);<br />
                }<br />
            }<br />
        }<br />
        catch(LocationException e){<br />
            stat.setText(&#8221;Exception: &#8220;+e.getMessage());</p>
<p>        }<br />
        catch(InterruptedException e){<br />
            stat.setText(&#8221;Timeout: &#8220;+e.getMessage());<br />
        }</p>
<p>    }<br />
  }<br />
     void testGET(String sUrl) throws IOException {<br />
         sUrl =&#8221;http://tinygeocoder.com/create-api.php?g=&#8221;+lat+&#8221;,&#8221;+lon;<br />
HttpConnection connection = null;<br />
InputStream is = null;<br />
 String sb = null;</p>
<p>try {<br />
connection = (HttpConnection)Connector.open(sUrl);<br />
connection.setRequestMethod(HttpConnection.GET);<br />
is = connection.openInputStream();<br />
byte buf[] = new byte[128];<br />
                    int total =0;<br />
                    while (total &lt;128) {<br />
                        int count = is.read(buf,total,128-total);<br />
                        if (count&lt;0) {<br />
                            break;<br />
                        }<br />
                        total += count;<br />
                    }<br />
    sb=new String(buf,0,total);<br />
  if (sb.length() =0&#215;30 &amp;&amp; b=0&#215;41 &amp;&amp; b=0&#215;61 &amp;&amp; b&lt;=0&#215;7A)) {<br />
                        tmp.append((char)b);<br />
                    }<br />
                    else {<br />
                        tmp.append(&quot;%&quot;);<br />
                        if (b &lt;= 0xf) tmp.append(&quot;0&quot;);<br />
                        tmp.append(Integer.toHexString(b));<br />
                    }<br />
                }<br />
            }<br />
            catch (Exception e) {}<br />
            return tmp.toString();<br />
        }<br />
        return null;<br />
}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: santhosh</title>
		<link>http://mobilepit.com/02/javame-jsr-179-example-code-detect-location-via-tinygeocoder.html/comment-page-1#comment-14766</link>
		<dc:creator>santhosh</dc:creator>
		<pubDate>Tue, 01 Sep 2009 09:49:59 +0000</pubDate>
		<guid isPermaLink="false">http://mobilepit.com/?p=142#comment-14766</guid>
		<description>Hai,

 I tried this code in Nokia E 71 mobile, it&#039;s working fine for showing the coordinates, but it could not represent the location info.

Could you please provide informatiom.

Thanks,
Regards,
Santhosh.</description>
		<content:encoded><![CDATA[<p>Hai,</p>
<p> I tried this code in Nokia E 71 mobile, it&#8217;s working fine for showing the coordinates, but it could not represent the location info.</p>
<p>Could you please provide informatiom.</p>
<p>Thanks,<br />
Regards,<br />
Santhosh.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NotoriousNew-B</title>
		<link>http://mobilepit.com/02/javame-jsr-179-example-code-detect-location-via-tinygeocoder.html/comment-page-1#comment-14731</link>
		<dc:creator>NotoriousNew-B</dc:creator>
		<pubDate>Sat, 01 Aug 2009 19:16:32 +0000</pubDate>
		<guid isPermaLink="false">http://mobilepit.com/?p=142#comment-14731</guid>
		<description>Hi there.

Is it possible to also display the location with maps (Google Maps, etc) on a J2ME application? If so, how?</description>
		<content:encoded><![CDATA[<p>Hi there.</p>
<p>Is it possible to also display the location with maps (Google Maps, etc) on a J2ME application? If so, how?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
