1 2 3 4 5 |
Android模拟器默认的地址是10.0.2.3,默认的DNS也是10.0.2.3,对于在家里上网学习Android的人来讲,一般电脑的IP都是192.168.1.100之类的,不在同一个网段。所以就会出现电脑可以上网但是模拟器不能上网的情况。其实设置方法很简单,只要把模拟器的默认DNS设置成电脑的DNS地址即可。 第一步:启动模拟器并确保adb连通 第二步:使用adb的shell,确认系统的各项属性 |
1 2 3 |
adb shell getprop |
1 2 3 4 5 |
getprop会列出系统当前的各项属性 第三步:得到模拟器的DNS地址 在结果里可以看到: |
1 2 3 4 |
[net.dns1]: [10.0.2.3] [net.dns2]: [10.0.2.4] [net.dns3]: [10.0.2.5] [net.dns4]: [10.0.2.6] |
1 |
第四步:把dns改成我们自己的DNS |
1 |
setprop net.dns1 192.168.1.1 |
1 |
<strong>注:一般TP-LINK及D-LINK的DNS都是192.168.1.1,如果不是请使用ipcnofig /all命令确认,另外,按照上面的步骤设置好后,需要在模拟器的Setting->无线网络设置里,把“启用数据流量”勾选上,让模拟器的TopTar上出现3G图标,才可上网~</strong> |
1 |
<strong> </strong> |
1 |
以上方法,在重启模拟器后设置的property会丢失,就需要重新设置一遍,可以使用下面的方法解决: |
1 2 3 |
找到你的SDK目录,里面有个system-images文件夹,这里保存着系统镜像文件,用文本编辑器打开里面的build.prop文件,在里面加上net.dns1=自己的DNS,保存;再重新创建模拟器即可~ 转自:<a href="http://www.cnblogs.com/flyme/archive/2011/11/14/2248213.html">http://www.cnblogs.com/flyme/archive/2011/11/14/2248213.html</a> |
下载Eclipse PDT All-In-One http://download.eclipse.org/tools/pdt/downloads/ 安装Zend Debugger · 选择Help->Software Updates->Find and Install · 选择 Search for new features to install, 点击 Next · 点击 the New Remote Site 按钮… Name: Zend Debugger URL: http://downloads.zend.com/pdt · Zend Debugger 现在在Sites to include in search 列表被选中, 点击 Finish按钮。 同样的方式安装JSEclipse(如果需要团队合作还可以装上Subclipse提供对Subversion 的支持) Name: JSEclipse URL: http://download.macromedia.com/pub/labs/jseclipse/autoinstall Name: Subclipse 1.2.x URL: http://subclipse.tigris.org/update_1.2.x Name: Aptana URL: http://update.aptana.com/update/3.2/ PDT调试方法 PHP Executable Debugger Zend Executable Debugger – 免费的Eclipse插件,在Eclipse 环境提供可执行的调试功能 PHP Web Server Debugger Zend Web Server Debugger – 安装在Web 服务器端的调试工具 XDebug Components – XDebug用于Web 服务器端的调试 注:版本发布类型 Released Builds – 稳定经过测试的发布版,可能不包含最新的功能特性 Stable […]
View Detailsnode.js Tools for Visual Studio 提供了在 Visual Studio 中开发 Node.js 应用的扩展。 软件首页 软件下载 转自:http://www.oschina.net/p/nodejstools
View DetailsFrom Update Site Prerequisites Installed and running Eclipse Classic 3.7 The minimum package is Eclipse Platform Runtime Binary. It is available at here Any packages in Eclipse Downloads page are available also. Installation Flow Open Help -> Install New Software. Select the Indigo update site. When the list of existing features is populated – select 'PHP Development Tools'. Make sure 'Contact all update sites…' is checked. Proceed with the installation by pressing 'Next', then press 'Next' again in the next screen. Accept the EULA when asked: Finish the […]
View Details1、搭建好android开发环境 2、启动android虚拟机(Eclipse下启动也可) 3、Windows系统打开cmd,进入android-sdk-windows\platform-tools目录 4、输入 adb install xxx.apk ;注意cmd下安装时不要使用中文,避免发生错误 5、刷新android虚拟机桌面,测试该应用程序 在android虚拟机中安装文件管理器后,即可进入文件管理操作; 在电脑上下载安装包 xxx.apk 后安装该软件到android虚拟机中,再借助文件管理器进行更简便的安装操作 转自:http://wu110cheng.blog.163.com/blog/static/133349654201232242429902/
View DetailsQR二维码比其他二维码相比,具有识读速度快、数据密度大、占用空间小的优势。QR码的三个角上有三个寻象图形,使用CCD识读设备来探测码的位置、大小、倾斜角度、并加以解码,实现360度高速识读。每秒可以识读30个含有100个字符QR码。QR码容量密度 大,可以放入1817个汉字、7089个数字、4200个英文字母。QR码用数据压缩方式表示汉字,仅用13bit即可表示一个汉字,比其他二维条码表示汉字的效率提高了20%。QR具有4个等级的纠错功能,即使破损也能够正确识读。QR码抗弯曲的性能强,通过QR码中的每隔一定的间隔配置有校正图形,从码的外形来求得推测校正图形中心点与实际校正图形中心点的误差来修正各个模快的中心距离,即使将QR码贴在弯曲的物品上也能够快速识读。QR码可以分割成16个QR码,可以一次性识读数个分割码,适应于印刷面积有限及细长空间印刷的需要。此外微型QR码可以在1厘米的空间内放入35个数字或9个汉字或21个英文字母,适合对小型电路板对ID号码进行采集的需要。(From:http://tuqiang9999.blog.163.com/blog/static/33241320111115103159542/) QRCode下载地址:ThoughtWorks.QRCode(支持中文) 一、项目引用QRCode的DLL文件(ThoughtWorks.QRCode.dll) 二、ASPX页面(两个jquery的js文件请自行去官网下载): <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>二维码工具测试</title> <script type="text/javascript" src="../../Scripts/Jquery/jquery-1.6.2.js"></script> <script type="text/javascript" src="../../Scripts/Jquery/jquery.form.js"></script> <script type="text/javascript" src="js/test.js"></script> <style type="text/css"> .style1 { width: 100%; } #txt_qr { width: 632px; } </style> </head> <body> <div> <table class="style1"> <tr> <td> 输入文字: </td> <td> <input type="text" id="txt_qr" name="txt_qr" /> </td> </tr> <tr> <td> 二维码图片 </td> <td> <img id="qrimg" alt="二维码图片" /> </td> </tr> <tr> <td> 生成选项 </td> <td> Encoding:<select id="Encoding"> <option value="Byte">Byte</option> <option value="AlphaNumeric">AlphaNumeric</option> <option value="Numeric">Numeric</option> </select> Correction Level:<select id="Level"> <option value="M">M</option> <option value="L">L</option> <option value="Q">Q</option> <option value="H">H</option> </select> Version:<input id="txt_ver" type="text" value="7" />(1-40) Size:<input id="txt_size" type="text" value="4" /> </td> </tr> <tr> <td colspan="4"> <input type="button" onclick="getQrImg();" value="生成二维码" /> </td> </tr> <tr> <td> <form id="qrForm" action="Ashx/test.ashx" method="post" enctype="multipart/form-data"> <input type="file" id="file_qr" name="file_qr" /><input type="submit" value="读取二维码" /> </form> </td> <td colspan="1"> <img id="img_qr" alt="要读取的图片" /><br /> <input id="txt_readqr" type="text" /> </td> </tr> </table> </div> </body> </html> 三、test.js文件 [javascript] $(document).ready(function () { var options = { beforeSubmit: showRequest, […]
View Details一、Views文件夹 -> Shared文件夹下的 _Layout.cshtml 母版页 @RenderBody 当创建基于_Layout.cshtml布局页面的视图时,视图的内容会和布局页面合并,而新创建视图的内容会通过_Layout.cshtml布局页面的@RenderBody()方法呈现在标签之间。 @RenderPage 从名称可以猜出来这个方法是要呈现一个页面。比如网页中固定的头部可以单独放在一个共享的视图文件中,然后在布局页面中通过这个方法调用,用法如下: @RenderPage(“~/Views/Shared/_Header.cshtml”) 带参数 @RenderPage(“~/Views/Shared/_Header.cshtml”,new{parm="my",parm2="you") 调用页面获取参数: //获取 RenderPage() 传递过来的参数 @PageData["param"] @RenderSection 布局页面还有节(Section)的概念,也就是说,如果某个视图模板中定义了一个节,那么可以把它单独呈现出来 为了防止因缺少节而出现异常,可以给RenderSection()提供第2个参数: @RenderSection("head", false) 或 @if (IsSectionDefined("head")) { @RenderSection("head", false) } else { <p>SubMenu Section is not defined!</p> } 代码如下: [html] view plaincopy <!DOCTYPE html> <html> <head> <title>@ViewBag.Title</title> <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script> @RenderSection("head", required: true)@*View页面自定义特定js/css使用*@ </head> <body> @RenderPage("~/Views/Shared/_Header.cshtml") @RenderBody() </body> </html> 二、创建视图,使用母版页 代码如下: [html] view plaincopy @{ ViewBag.Title = "Index"; Layout = "~/Views/Shared/_Layout.cshtml"; } <h2>Index</h2> @section Head{ <script type="text/javascript"> $(function () { alert("hello jquery"); }); </script> } <p>执行C#普通语法</p><br /> @DateTime.Now.Date.ToShortDateString() <p>执行C#语句段</p> @{ List<string> list = new List<string> { "Mvc3", "Razor" }; list.Add(".Net4"); } <ul> @foreach(string s in list) { if (string.IsNullOrEmpty(s)) { <li>空</li> } else […]
View Details设当前页完整地址是:http://www.jb51.net/aaa/bbb.aspx?id=5&name=kelli "http://"是协议名 "www.jb51.net"是域名 "aaa"是站点名 "bbb.aspx"是页面名(文件名) "id=5&name=kelli"是参数 【1】获取 完整url (协议名+域名+站点名+文件名+参数) 复制代码代码如下: string url=Request.Url.ToString(); url= http://www.jb51.net/aaa/bbb.aspx?id=5&name=kelli 【2】获取 站点名+页面名+参数: 复制代码代码如下: string url=Request.RawUrl; (或 string url=Request.Url.PathAndQuery;) url= /aaa/bbb.aspx?id=5&name=kelli 【3】获取 站点名+页面名: 复制代码代码如下: string url=HttpContext.Current.Request.Url.AbsolutePath; (或 string url= HttpContext.Current.Request.Path;) url= aaa/bbb.aspx 【4】获取 域名: 复制代码代码如下: string url=HttpContext.Current.Request.Url.Host; url= www.jb51.net 【5】获取 参数: 复制代码代码如下: string url= HttpContext.Current.Request.Url.Query; url= ?id=5&name=kelli 复制代码代码如下: Request.RawUrl:获取客户端请求的URL信息(不包括主机和端口)——>/Default2.aspx Request.ApplicationPath:获取服务器上ASP.NET应用程序的虚拟路径。——>/ Request.CurrentExecutionFilePath:获取当前请求的虚拟路径。——>/Default2.aspx Request.Path:获取当前请求的虚拟路径。——>/Default2.aspx Request.PathInfo:取具有URL扩展名的资源的附加路径信息——> Request.PhysicalPath:获取与请求的URL相对应的物理文件系统路径。——>E:\temp\Default2.aspx Request.Url.LocalPath:——>/Default2.aspx Request.Url.AbsoluteUri:——>http://localhost:8080/Default2.aspx Request.Url.AbsolutePath:—————————->/Default2.aspx 转自:脚本无忧
View Details1、Byte[] ===== 1. BitConverter 将基础数据类型与字节数组相互转换。注意string不是基础类型,而且该方法在不同平台间传递可能有误。 int i = 13; byte[] bs = BitConverter.GetBytes(i); Console.WriteLine(BitConverter.ToInt32(bs, 0)); 2. Encoding 注意慎用Encoding.Default,其值取自操作系统当前的设置,因此在不同语言版本的操作系统是不相同的。建议使用UTF8或者GetEncoding(”gb2312″)。 string s = "abc"; byte[] bs = Encoding.UTF8.GetBytes(s); Console.WriteLine(Encoding.UTF8.GetString(bs)); 3. BinaryFormatter 以二进制格式将对象或整个连接对象图形序列化和反序列化。 using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; [Serializable] class Data { private int x = 13; public void Test() { Console.WriteLine(x); } } static void Main(string[] args) { Data data = new Data(); MemoryStream stream = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, data); byte[] bs = stream.ToArray(); MemoryStream stream2 = new MemoryStream(bs); Data data2 = (Data)formatter.Deserialize(stream2); data2.Test(); } […]
View DetailsWeb.Config
1 |
<globalization responseEncoding="gb2312"/> |
CS文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net; using System.Text; using System.IO; using System.Xml; using System.Collections; using System.Diagnostics; namespace WebPortal { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { CoreProxy.Class1 c = new CoreProxy.Class1(); c.test1(); } protected void Button2_Click(object sender, EventArgs e) { webquerst1(); } public void webquers2() { string html = null; string url = "http://china.alibaba.com/keyword/promotion.htm?catId=14"; WebRequest req = WebRequest.Create(url); req.Method = "POST"; WebResponse res = req.GetResponse(); Stream receiveStream = res.GetResponseStream(); Encoding encode = Encoding.GetEncoding("gb2312"); StreamReader sr = new StreamReader(receiveStream, encode); char[] readbuffer = new char[256]; int n = sr.Read(readbuffer, 0, 256); while (n > 0) { string str = new string(readbuffer, 0, n); html += str; n = sr.Read(readbuffer, 0, 256); } System.Console.Write(html); } //成功!,利用WebRequest 一次Post提交XML内容 public void webquerst1() { WebRequest request = WebRequest.Create("http://192.168.1.244/WebPortal/PortalHandler.ashx"); // Set the Method property of the request to POST. request.Method = "POST"; // Create POST data and convert it to a byte array. System.Xml.XmlDocument xmlpostdata = new System.Xml.XmlDocument(); xmlpostdata.Load(Server.MapPath("XML/20097.xml")); string postData = HttpUtility.HtmlEncode(xmlpostdata.InnerXml); //普通字符串内容 //string postData = "你好,1232355 abdcde"; byte[] byteArray = Encoding.UTF8.GetBytes(postData); // Set the ContentType property of the WebRequest. request.ContentType = "application/x-www-form-urlencoded"; // Set the ContentLength property of the WebRequest. request.ContentLength = byteArray.Length; // Get the request stream. Stream dataStream = request.GetRequestStream(); // Write the data to the request stream. dataStream.Write(byteArray, 0, byteArray.Length); // Close the Stream object. dataStream.Close(); // Get the response. WebResponse response = request.GetResponse(); // Display the status. //Console.WriteLine(((HttpWebResponse)response).StatusDescription); // Get the stream containing content returned by the server. dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access. StreamReader reader = new StreamReader(dataStream); // Read the content. string responseFromServer = reader.ReadToEnd(); // Display the content. //Console.WriteLine(responseFromServer); // Clean up the streams. reader.Close(); dataStream.Close(); response.Close(); } protected void Button3_Click(object sender, EventArgs e) { WebClientPost(); } //重点!! 成功 利用Webclient Post 按字段的方式提交每个字段的内容给服务器端 public void WebClientPost() { System.Xml.XmlDocument xmlpostdata = new System.Xml.XmlDocument(); xmlpostdata.Load(Server.MapPath("XML/OrderClient.xml")); string OrderClient = HttpUtility.HtmlEncode(xmlpostdata.InnerXml); xmlpostdata.Load(Server.MapPath("XML/Order.xml")); string Order = HttpUtility.HtmlEncode(xmlpostdata.InnerXml); xmlpostdata.Load(Server.MapPath("XML/TargetOut.xml")); string TargetOut = HttpUtility.HtmlEncode(xmlpostdata.InnerXml); xmlpostdata.Load(Server.MapPath("XML/ArrayOfOrderDetail.xml")); string ArrayOfOrderDetail = HttpUtility.HtmlEncode(xmlpostdata.InnerXml); System.Net.WebClient WebClientObj = new System.Net.WebClient(); System.Collections.Specialized.NameValueCollection PostVars = new System.Collections.Specialized.NameValueCollection(); //添加值域 PostVars.Add("OrderClient", OrderClient); PostVars.Add("Order", Order); PostVars.Add("TargetOut", TargetOut); PostVars.Add("ArrayOfOrderDetail", ArrayOfOrderDetail); try { byte[] byRemoteInfo = WebClientObj.UploadValues("http://192.168.1.244/WebPortal/PlaceOrder.ashx", "POST", PostVars); //下面都没用啦,就上面一句话就可以了 string sRemoteInfo = System.Text.Encoding.Default.GetString(byRemoteInfo); //这是获取返回信息 Debug.WriteLine(sRemoteInfo); } catch { } } //未测试,使用WebClient 一次性提交POst public static string SendPostRequest(string url, string postString) { byte[] postData = Encoding.UTF8.GetBytes(postString); WebClient client = new WebClient(); client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); client.Headers.Add("ContentLength", postData.Length.ToString()); byte[] responseData = client.UploadData(url, "POST", postData); return Encoding.Default.GetString(responseData); } /// <summary> /// 这个是用WEbRequest 提交到WEbService 的例子 /// </summary> /// <param name="URL"></param> /// <param name="MethodName"></param> /// <param name="Pars"></param> /// <returns></returns> public static XmlDocument QueryPostWebService(String URL, String MethodName, Hashtable Pars) { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; SetWebRequest(request); byte[] data = EncodePars(Pars); WriteRequestData(request, data); return ReadXmlResponse(request.GetResponse()); } private static void SetWebRequest(HttpWebRequest request) { request.Credentials = CredentialCache.DefaultCredentials; request.Timeout = 10000; } private static void WriteRequestData(HttpWebRequest request, byte[] data) { request.ContentLength = data.Length; Stream writer = request.GetRequestStream(); writer.Write(data, 0, data.Length); writer.Close(); } private static byte[] EncodePars(Hashtable Pars) { return Encoding.UTF8.GetBytes(ParsToString(Pars)); } private static String ParsToString(Hashtable Pars) { StringBuilder sb = new StringBuilder(); foreach (string k in Pars.Keys) { if (sb.Length > 0) { sb.Append("&"); } sb.Append(HttpUtility.UrlEncode(k) + "=" + HttpUtility.UrlEncode(Pars[k].ToString())); } return sb.ToString(); } private static XmlDocument ReadXmlResponse(WebResponse response) { StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8); String retXml = sr.ReadToEnd(); sr.Close(); XmlDocument doc = new XmlDocument(); doc.LoadXml(retXml); return doc; } private static void AddDelaration(XmlDocument doc) { XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "utf-8", null); doc.InsertBefore(decl, doc.DocumentElement); } protected void Button4_Click(object sender, EventArgs e) { } } } |
ashx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Diagnostics; using System.IO; using System.Xml; namespace WebPortal { /// <summary> /// $codebehindclassname$ 的摘要说明 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class PortalHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { string testGet = context.Request["testGet"]; string testPost = context.Request["testPost"]; Debug.WriteLine(testGet); Debug.WriteLine(testPost); //一次性提交的方式 //获得内容长度 int len = context.Request.ContentLength; //获得所有内容流 StreamReader reader = new StreamReader(context.Request.InputStream); //读取内容 string responseFromServer = reader.ReadToEnd(); //字段提交Post方式 string a1 = context.Request["A1"]; string a2 = context.Request["A2"]; string a3 = context.Request["A3"]; //解析Html编码 string re = HttpUtility.HtmlDecode(a1); XmlDocument xd = new XmlDocument(); //加载XML xd.LoadXml(re); context.Response.ContentType = "text/plain"; context.Response.Write(testGet); } public bool IsReusable { get { return false; } } } } |
转自:http://www.cnblogs.com/goody9807/archive/2011/10/08/2202265.html
View Details