在Android中使用PhoneGap进行异步任务

时间:2014-09-15 10:25:43

标签: java android cordova android-asynctask

这里我想调用html pages.I使用Phone Gap。但是现在我想用AsyncTask调用html页面。所以有人可以帮助我如何调用
super.loadUrl(" file:///android_asset/www/chapter_one.html",10000);在AsyncTask中。

这是我的活动代码。

public class Chapter_Detail extends DroidGap
{
    public void onCreate(Bundle savedInstanceState)
    {
          super.onCreate(savedInstanceState);

          Intent intent = getIntent();
          String stringContent = intent.getExtras().getString("Chapter_Content");
          Log.e("stringContent in Performance Details  "," = " + stringContent);

          if(stringContent.equals("oop concept"))
          {
              super.loadUrl("file:///android_asset/www/chapter_one.html", 10000);
          }
        }
     }

1 个答案:

答案 0 :(得分:1)

你需要在ajax调用的帮助下完成。下面的代码调用服务url,你将得到响应。

function callRest(uName, pwd, serviceUrl, pxml) 
            {
          $.support.cors = true;
            $.ajax({
                cache: false,
                type: "GET",
                url: serviceUrl,
                dataType: "text",
                username: uName,
                password: pwd,
                statusCode: {
                    200: function () {

                    },
                    500: function () {

                    }
                },

                success: function (res, status, xhr) {
                //res contains response,
                },
                error: function (XMLHttpRequest, status, error_is) {
                    alert('Error: ' + error_is);
                }
            });
        }
相关问题