通过webview查询字符串的url

时间:2014-07-11 00:03:53

标签: android android-webview

我试图通过webview查询带有查询字符串的url,但它无效。我无法在服务器端获得价值,但如果点击链接浏览器如googlechorme它可以正常工作。

编辑:通过代码点击链接

private void sendMacId()
    {
        Thread thread = new Thread()
        {
            public void run()
            {
                super.run();

                String url = "http://www.site.org/index.html?device_id="+getMacAddress()+"";

                try 
                {
                    HttpClient httpclient = new DefaultHttpClient();
                    HttpGet httpget = new HttpGet(url);
                    httpclient.execute(httpget);
                    Log.v(TAG, "sent...");
                } 
                catch (ClientProtocolException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        };

         thread.start();
    }

编辑:index.html代码

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <title></title>



    <link rel="stylesheet" href="jquery.mobile-1.3.1.min.css">

  <!-- Extra Codiqa features -->
  <link rel="stylesheet" href="codiqa.ext.css">

  <!-- jQuery and jQuery Mobile -->
  <script src="https://d10ajoocuyu32n.cloudfront.net/jquery-1.9.1.min.js"></script>
  <script src="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
 <script src="mscript.js"></script>
  <!-- Extra Codiqa features -->
  <script src="https://d10ajoocuyu32n.cloudfront.net/codiqa.ext.js"></script>

<link href="style.css" rel="stylesheet" type="text/css">
<style>
.ui-body-c, .ui-overlay-c
{background-image:none;
background-repeat:no-repeat;
background-position:center;
}
</style>
<script src="mscript.js"></script>
</head>
<body>
<div id="fb-root"></div>
<script type="text/javascript">
(function($) {
    $.QueryString = (function(a) {
        if (a == "") return {};
        var b = {};
        for (var i = 0; i < a.length; ++i)
        {
            var p=a[i].split('=');
            if (p.length != 2) continue;
            b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
        }
        return b;
    })(window.location.search.substr(1).split('&'))
})(jQuery);

            device_id = $.QueryString["device_id"];
            if (device_id)
            {
                $.ajax('savedevice_id.php?device_id=' + device_id, function(response) {

                });
            }

//<![CDATA[
window.fbAsyncInit = function() {
   FB.init({
     appId      : '547732011957196', // App ID
     channelURL : '', // Channel File, not required so leave empty
     status     : true, // check login status
     cookie     : true, // enable cookies to allow the server to access the session
     oauth      : true, // enable OAuth 2.0
     xfbml      : false  // parse XFBML
   });
   FB.Event.subscribe('auth.login', function(response){
        window.location.reload();
    });
};
// logs the user in the application and facebook
function login(){

FB.getLoginStatus(function(r){
     if(r.status == 'connected'){

            window.location.href = 'facebook_data.php';
     }
     else
     {
        FB.login(function(response)
         {
     // alert("pp"+response.authResponse);

                if(response.authResponse) {
              //if (response.perms)
    //alert("wel");
                   window.location.href = 'facebook_data.php';
                //window.location.href = 'welcome.php';
            }
             else
             { //  alert("adc");

              // user is not logged in
            }
     },{scope:'email'}); // which data to access from user profile
 }
});
}

// Load the SDK Asynchronously
(function() {
   var e = document.createElement('script'); e.async = true;
   e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';                
   document.getElementById('fb-root').appendChild(e);
}());
//]]>
</script>


<fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button>
<!-- Home -->
<div data-role="page" id="page-home" data-cache="never">

    <div data-role="content" style="padding:0px;" data-dom-cache="false">

    <img src="images/splash1.png" width="320" height="480" border="0" align="middle" usemap="#Map">
    <map name="Map">
      <area shape="rect" coords="57,377,262,411" href="facebook_data.php">
    </map>
    <br>
    <a href="javascript:void(0)" onClick="window.open('user-account.php','_self')" style="color:#FFF;font-size: 12px;margin-left: 50px; margin-top: -50px;position: absolute;text-align: center;z-index: 1000; text-decoration:none;  font-weight: 100; display:block; padding:10px; border:0px">Don't have Facebook? Login with email.</a>
    </div>
</div>
</body>
</html>

0 个答案:

没有答案