Re: [android-developers] How best to query web repeatedly.

2011-01-14 Thread Kumar Bibek
Well, you have to decide what's best for your application.
1. Spawn any number of threads, but manage them properly
2. Preferably.
3. Good idea.

Kumar Bibek
http://techdroid.kbeanie.com
http://www.kbeanie.com



On Sat, Jan 15, 2011 at 9:42 AM, cellurl  wrote:

> I run GPS, and query a web based mysql every 50 meters of driving.
> People tell me the app locks up and has lag, so I put each query in a
> new thread. This seems to create a backlog of threads (at least in the
> emulator).
>
>URL url = new URL("http://www.website.org/marks.php";);
>
>HttpURLConnection urlConn = (HttpURLConnection) url
>.openConnection();
>BufferedReader in = new BufferedReader(new InputStreamReader(
>urlConn.getInputStream()));
>String inputLine;
>while ((inputLine = in.readLine()) != null)
>response.append( inputLine );
>
> 1. Are dozens of threads wrong? Do I just use two and leave it at
> that?
> 2. Should I keep connection open as I have heard others speak of?
> 3. Will I ultimately be forced to sqlite and the new headache of db
> synchronization?
>
> Anyone have any experience to offer?
>
> Thanks in advance,
> -cellurl
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] How best to query web repeatedly.

2011-01-14 Thread cellurl
I run GPS, and query a web based mysql every 50 meters of driving.
People tell me the app locks up and has lag, so I put each query in a
new thread. This seems to create a backlog of threads (at least in the
emulator).

URL url = new URL("http://www.website.org/marks.php";);

HttpURLConnection urlConn = (HttpURLConnection) url
.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
urlConn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
response.append( inputLine );

1. Are dozens of threads wrong? Do I just use two and leave it at
that?
2. Should I keep connection open as I have heard others speak of?
3. Will I ultimately be forced to sqlite and the new headache of db
synchronization?

Anyone have any experience to offer?

Thanks in advance,
-cellurl

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en