trying out some basic html scripts with sl4a and my python application can't seem to call the HTML... trying to send data from a small form in the HTML over to the python side
here's the HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HTML form</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<div id="body">
<h1>My Settings</h1>
<script type="text/javascript">
var droid = new Android();
function post_data(){
var values = [
['airplane', document.getElementById('airplane_mode').value],
['wifi', document.getElementById('wifi_on').value],
['brightness', document.getElementById('brightness').value],
['volume', document.getElementById('volume').value],
];
var q = '?';
for (i=0;i<values.length;i++){
var k = values[i][0];
var v = values[i][1];
if (q != '?'){
q = q + '&';
}
q = q + k + '=' + v;
}
droid.postEvent('save', q);
}
</script>
<form onsubmit="post_data();">
<div class="container">
<div>
<label for="airplane_mode">Airplane Mode</label>
<input id="airplane_mode" name="radio" type="radio" />
</div>
<div>
<label for="wifi_on">WiFi On</label>
<input id="wifi_on" name="radio" type="radio" />
</div>
<div>
<label for="off">Both off</label>
<input id="off" name="radio" type="radio" />
</div>
</div>
<div class="container">
<div>
<label for="brightness">Brightness Level</label>
<input size="5" id="brightness" type="text" />
</div>
<div>
<label for="volume">Media Volume</label>
<input size="5" id="volume" type="text" />
</div>
</div>
<div class="container buttons">
<div>
<input size="5" id="save" name="save" type="submit" value="Save Settings" />
<input size="5" id="cancel" name="cancel" type="button" value="Cancel" />
</div>
</div>
</form>
</div>
</body>
</html>
here's the python end that uses the values passed from the js in the HTML to alter some phone options
import android
import urlparse
droid = android.Android()
droid.webViewShow('file:///tablet/sl4a/scripts/html/options.html')
while True:
result = droid.eventWaitFor('save').result
data = urlparse.parse_qs(result['data'][1:])
droid.toggleAirplaneMode('airplane' in data)
print 'airplane' in data
droid.toggleWifiState('wifi' in data)
print 'wifi' in data
droid.setScreenBrightness('screen' in data and 255 or 0)
thing is once I execute the python code, it does not call the webViewShow at all and simply closes stating that the response is not parseable because it's value is none, not a tuple so where exactly did I go wrong?
update: Tried different formats for the url so none worked. the webview itself is not being called
update 2: okay... webview is opening but all I get is a blank page that forces me to perform a hard kill using the task manager as sl4a freezes up there, as if it's trying to render the html
update 3: had the webViewShow refer to a non existent address and the screen issue keeps on happening. any ideas?
Py4A is the latest and SL4A version is R6. running on android 4.1.2