how to push data from internet to android? scrolling? zoom?

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

how to push data from internet to android? scrolling? zoom?

Postby mikeghtmare » Sat Apr 24, 2010 12:32 am

Hello everyone, I've got three questions I hope you can point me in the right direction. Thanks a lot :D

My first question is regarding pushing data from the internet to the android. Basically I want to update a database on my website and have the info/data propagate to all users of my App... is there a way to push the data only when new data is added to the database? Or do I have to have the App querying like every 5 minutes for example to check for new data? And if I have to query every 'x' minutes, do I need to use a specific Android library or do I do it using regular Java database statements to create a connection and do the query?

My second question is regarding scrolling. I need to do vertical and horizontal scrolling and so far the only way I've been able to do it is by nesting a ScrollView inside a horizontalScrollView, but I've noticed it's not too responsive and it doesn't work as expected if you move the finger diagonally. Is there another way to accomplish this?

And finally, the third question I have is whether it's possible to change the zoom value when using views other than the webview? This would come in handy for the view I have which needs vertical and horizontal scrolling.

Thank you once again.
mikeghtmare
Freshman
Freshman
 
Posts: 7
Joined: Fri Feb 26, 2010 2:43 am

Top

Postby mikeghtmare » Mon Apr 26, 2010 6:52 pm

anyone? :oops:
I just need to be pointed the right direction. Thanks.
mikeghtmare
Freshman
Freshman
 
Posts: 7
Joined: Fri Feb 26, 2010 2:43 am

Postby Stevos » Thu Apr 29, 2010 5:05 pm

Hi,

As for the first question, it's trickier than it should be (IMO). I have also been trying to work out a way around it. Sadly I suspect it falls outside the realm of "novice tutorials."

Google implemented a push notification system based on XMPP specifically for their GTalk stuff, Originally they planned to open this to every app developer to allow them to use push notifications in other software (you may have seen some youtube videos with talk to this effect), however they apparently ran into some security and management problems with this approach (to do with tying the XMPP credentials into a Google / Gmail account), so they removed it.

If you search around the web for XMPP (Jabber) and android you may be able to find some useful information on the topic. The best looking sample I have found is here http://davanum.wordpress.com/2007/12/31 ... -for-xmpp/ (note the newer code sample linked at the top of the page.) I think it uses a JAR library for Smack (which I'm given to understand is the underlying code that the GTalk stuff uses anyway.)

I haven't tried to get this working yet as I'm trying to get my head around the underlying technologies, so I can't warrant that the code is any use.

The other approach is to use a long-polling pull technique such as COMET. This would usually be superior to timed polling, as it gives an "instant" update when the server state changes. http://en.wikipedia.org/wiki/Comet_(programming.) Again, searching the web may provide useful examples.

Sorry I couldn't be more help, but hopefully that will give you something to base your research on.
Stevos
Freshman
Freshman
 
Posts: 8
Joined: Wed Mar 24, 2010 3:17 pm

Postby Stevos » Thu Apr 29, 2010 5:13 pm

Just another note to add to the above...

Be aware of the battery issues you may run into if you have the processor running updates from a background process. I remember seeing one of the platform doc videos say that every time a poll causes the CPU to wake up, a load of other processes may "piggyback" on the wakeup, and run their code, and then the processor and system take several seconds to return to low power sleep mode. This means that if you run an update once every 5 minutes, you may end up with the cpu running full whack for 30 seconds out of every 5 minutes, which would cause battery drain.

I'm not sure if a COMET approach would be better or worse, as you may be able to get the processor to fullly wake only on receiving new data. Someone probably has good info on this.

We could really do with a robust platform supported push notifcation system where all app and system updates can be pooled into one thread (a la iPhone I think.) I thought that was what we were going to get with the gtalk/xmpp thing, but evidently not.
Stevos
Freshman
Freshman
 
Posts: 8
Joined: Wed Mar 24, 2010 3:17 pm

Postby mikeghtmare » Thu Apr 29, 2010 6:51 pm

Thanks a lot Stevos. I'm new to Anroid development but not new to programming so hopefully I can get things to work with the links and info you provided. Thanks also for the heads-up on the battery usage; I guess worst case scenario if I don't have another solution I can do the polling only when user manually gets out of standby, or when they manually open the app but in that case there will be no point in sending notification.

Have a good day. Thanks again :D
mikeghtmare
Freshman
Freshman
 
Posts: 7
Joined: Fri Feb 26, 2010 2:43 am

Postby DMacATTACK » Sat May 01, 2010 6:11 am

mikeghtmare:
I was thinking of utilizing a similar concept where my computer sends me information. Although I haven't had much time to try it out, I was thinking of doing the same idea using socket connections, specifically an Asynchronous TCP Connection. This point of view mainly stems from my programming experience in other fields, I have no idea how well it would work, or battery usage, but its definitely food for thought.
Let us know how things work out.

Dan
User avatar
DMacATTACK
Experienced Developer
Experienced Developer
 
Posts: 58
Joined: Thu Dec 31, 2009 6:31 pm
Location: Canada

Top

Re: how to push data from internet to android? scrolling? zo

Postby mikeghtmare » Wed Jun 23, 2010 12:43 am

DMacATTACK:
FYI, I opted to do an update when the app is launched and also provide an update menu option so users can update when they are actually using the app.
mikeghtmare
Freshman
Freshman
 
Posts: 7
Joined: Fri Feb 26, 2010 2:43 am

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 7 guests