Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8819441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:21:35+00:00 2026-06-14T05:21:35+00:00

I created a native Android app using the Android SDK and java packages, using

  • 0

I created a native Android app using the Android SDK and java packages, using a ASP.Net Web service created by me, and it works fine. But now I want to make this cross-platform. I heard that Phonegap and jQuery Mobile will help with this, but I am still a bit confused.

  1. Is it necessary to host the HTML file that uses Javascript to work properly?
    OR
  2. Can I include the HTML and js file in my application and call the web service methods?

Can somebody please guide me?

MY Demo Code is

JAVA SCRIPT

<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
 <script src="jquery-1.7.2.min"></script>
 <script src="jquery.mobile-1.1.1.min.js"></script>
<script type="text/javascript" charset="utf-8"/></script>

<link rel="stylesheet" src="jquery.mobile-1.1.1.min.css"/>
  <script type="text/javascript">


function onDeviceReady() {}
document.addEventListener("deviceready", onDeviceReady, false);

function LoginButton_onclick() {
    $.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
    url:    "http://182.72.192.18/webservicedemo/service.asmx/HelloWorld",
    data: '{}',
    success: function(msg) {
   jsonArray = $.parseJSON(msg.d);
    var $ul = $( '<ul id="details">' );
    for(i=0; i < jsonArray.length; i++)
    {
  $("#details").append('<li id="'+i+'" name="head" >'+jsonArray[i].name+'</li>' );
} $('#details').listview('refresh');
    },
    error: function(msg) {
         alert("Error");
    }
});

</script>

HTML

<div data-role="page" id="Page1">
<h1>DEMO PAGE</h1>

<div id="DEMO"> 
<input id="LoginButton" type="button" value="GET DATA" onclick="LoginButton_onclick()" /></div>

<div id="divList" data-role="content">
<ul id="details" data-role="listview" data-inset="true"></ul>
</div>

</div>     
</body>

and my ASP.NET Web Service is

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService{
JavaScriptSerializer serializer = new JavaScriptSerializer();
public Service () {}

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string HelloWorld() {

    List<clsDetails> deailsList = new List<clsDetails>{
    new clsDetails(1,"BOY","SCHOOL"),
    new clsDetails(2,"GIRL","COLLEGE"),
    new clsDetails(3,"MAN","OFFICE")};

    string detail = serializer.Serialize(deailsList);
    return detail;
}
}

if i host the html file along with my web-service it provide me result .
but when i try to call using a local html file from android app it fails.
i can’t figure out what went wrong.

Can anyone tell me what went wrong here?
Look here is the response i get from web-service and i parse that to JSON

HTML HOSTED ALONG WITH WEBSERVICE

phonegap.xml

<phonegap>  
<access origin="http://182.72.192.18" /> 
</phonegap>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:21:36+00:00Added an answer on June 14, 2026 at 5:21 am

    You have to use a local html and get the server data using XHR calls to your webservice, and then show the data of your webservice in your html.

    Edit after seeing the code:

    The problem is the url. You can’t use localhost, because if you test on a device, localhost is the device, and the device doesn’t have the webservice, you have to use the local iP of your machine. http://192.168.1.XXX:1000/WebSite2/Service.asmx/HelloWorld

    Edit 2:
    I just tested your code and got it working for me, just change this.
    The jsonArray[i].Result didn’t work for me, it return undefined, but you can access to every attribute of the json object, in the example I used the name.
    And put the refresh outside the for, you only have to refresh when you finish, not every time, and put the ; at the end.

    for(i=0; i < jsonArray.length; i++)
        {
      $("#details").append('<li id="'+i+'" name="head" >'+jsonArray[i].name+'</li>' );
    
    }
    $('#details').listview('refresh');
    

    If it still don’t work, check if you whitelisted the domain phonegap whitelist guide

    Full working code

    <!DOCTYPE html>
    <html>
        <head>
            <title>DEMO</title>
            <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
            <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
            <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
            <title>DEMO</title>
            <script type="text/javascript" charset="utf-8">
    
                function LoginButton_onclick() {
                    $.ajax({
                           type: "POST",
                           contentType: "application/json; charset=utf-8",
                           dataType: "json",
                           url:    "http://182.72.192.18/webservicedemo/service.asmx/HelloWorld",
                           data: '{}',
                           success: function(msg) {
                           jsonArray = $.parseJSON(msg.d);
                           var $ul = $( '<ul id="details">' );
                           for(i=0; i < jsonArray.length; i++)
                           {
                           $("#details").append('<li id="'+i+'" name="head" >'+jsonArray[i].name+'</li>' );
                           }
                           $('#details').listview('refresh');
                           },
                           error: function(msg) {
                           alert("Error");
                           }
                           });
    
                }
    
    
                </script>
            </head>
            <body>
                <div data-role="page" id="Page1">
                    <h1>DEMO PAGE</h1>
    
                    <div id="DEMO">
                        <input id="LoginButton" type="button" value="GET DATA" onclick="LoginButton_onclick()" /></div>
    
                    <div id="divList" data-role="content">
                        <ul id="details" data-role="listview" data-inset="true"></ul>
                    </div>
    
                </div>
            </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a native Android app that basically hosts a webView control. That webView
I have created android phonegap app using html,css,javascript and jquery.When i hit the back
i have created an app in android using JNI,NDKand phonegap Plugin fr android. Here
To create facebook android native app we need to provide our Android application signature
I've inherited a small project. The person before me created a native app for
i've overloaded the Application class in my android app and i'm using the ACRA
at android.hardware.Camera.native_setParameters(Native Method) at android.hardware.Camera.setParameters(Camera.java:647) at com.CameraApp.Preview.surfaceChanged(Preview.java:67) at android.view.SurfaceView.updateWindow(SurfaceView.java:538) at android.view.SurfaceView.dispatchDraw(SurfaceView.java:339) at android.view.ViewGroup.drawChild(ViewGroup.java:1638) at
I got this error from the user logs on an android app I created.
I have an issue with SSO using the Facebook SDK for Android. The problem
I am trying to return a newly created java class object in native to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.