0

My app is basicly several pages made with jQuery Mobile. Right now, I just have one single Android activity that sets and cofigs the WebView, launching the first jQuery Mobile page stored in the asset folder. From there on, it is web technologies only. As nice as jQuery Mobile looks and works, I begin to feel limited.

The most important point is form processing. How can I transmit entered informations to the next page without any kind of server beneath it? Is there a HTML5 or Ajax way, or should I try to "connect" my current pages deeper with Android?

SDD64
  • 706
  • 13
  • 28

2 Answers2

1

You can use something called query strings to pass arguments between HTML pages. Instead of going to form2.html, you go to form2.html?foo=bar. Then you can use javascript to retrieve the arguments and process them into your webpage.

I use the following javscript function for this purpose:

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

It is not flawless when you use more complicated arguments between your webpages (think of special characters), but it does a basic job. If you want a more complete function look here: How can I get query string values in JavaScript?

Community
  • 1
  • 1
Calavoow
  • 492
  • 3
  • 19
0

If you want more deeper communication with Android go with the default language (java), but if you want a easy way but also a limiting go with the WebView. Also if you want to get information from a server its easier to get it through a ajax call and it will set up nicely with the jquery mobile you are using.I have seen some examples of getting information from a server to Android it looks like a lot of hard work> (coming from someone who's newish to programming android.

http://api.jquery.com/jQuery.ajax/

ryanc1256
  • 570
  • 6
  • 23
  • Well, there is no server used. It is basicly from one html file to another. If I go "the android way" and pass the informations to another activity, I fear to loose the nice jQuery transition effects. – SDD64 Jul 15 '12 at 16:03
  • yer ok, you would lose the transition affects that go with jquery. You might be able to get them with default android, you could just google "android transition affects" but im pretty sure you cant. – ryanc1256 Jul 17 '12 at 06:14
  • At last, I took the dirty method and just used a jQuery multipage template. – SDD64 Jul 18 '12 at 13:44