-1

im trying to set up a button in my android program that when pushed gets some information from a web api and displays the result on my screen.

this is the code that does all the work, but i need to put it in my android page:

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<script type="text/javascript">
<!--
function get_temp(){
var url = "http://api.wunderground.com/api/00000000003/conditions/q/';
    url+=$('#lat').val()+','+$('#lon').val()+' .json?callback=?';
    $('#log').html($('#log').html()+url);
    $.getJSON(url, function(data) {
        var temp = data['current_observation']['temp_c'];
        $('#out').html($('#shoedata').html()+temp+'<br>');
    });
 }
 //-->
</script>
Latitude <input type="text" name="name" id="lat" />
Longitude <input type="text" name="name" id="lon" />
<input value="Get temperatura" type="button" onclick="get_temp()"/>
<div id='out'>Current temperature: </div>
<div id="log">Log: </div>
</body>
</html>

How can i do this? what are the steps i should follow to write js code in android? is it any different also for jquery and jsonp? Thanks!

1
  • One does not write JS code in Android. In Android you going to instantiate a HttpClient that will do a GET or POST and the web server will return the information in JSON Commented Sep 3, 2013 at 10:11

1 Answer 1

0

Hi Friend use below given Links.

http://developer.android.com/reference/android/webkit/WebView.html

JSON,XML connecting to web api for Android?

Hope these will help you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.