mikebai.com

  • Home
  • dev
  • DotNET
  • M365
  • 搞笑
  • 杂七杂八
  • FocusDict
個人BLOG
it developer
dev

安卓手机admob广告无法显示的问题

这个问题恶心我好几天,我2个手机,其中的一个可以显示admob广告条,另一个死活出不来,后来发现android也有host文件控制跳转如果发现无法显示广告,logcat显示以下错误的话,查看/system/etc/host文件中是否将googleads.g.doubleclick.net转向了127.0.0.1将其注释后即可显示广告logcat info may be shown as follows:03-07 21:27:43.713: W/Ads(5189): IOException connecting to ad url.03-07 21:27:43.713: W/Ads(5189): java.net.ConnectException: googleads.g.doubleclick.net/127.0.0.1:80 - Connection refused03-07 21:27:43.713: W/Ads(5189):  at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:210)03-07 21:27:43.713: W/Ads(5189):  at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:440)03-07 21:27:43.713: W/Ads(5189):  at java.net.Socket.connect(Socket.java:1013)03-07 21:27:43.713: W/Ads(5189):  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:75)03-07 21:27:43.713: W/Ads(5189):  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)03-07 21:27:43.713: W/Ads(5189):  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322)03-07 21:27:43.713: W/Ads(5189):  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)03-07 21:27:43.713: W/Ads(5189):  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285)03-07 21:27:43.713: W/Ads(5189):  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267)03-07 21:27:43.713: W/Ads(5189):  at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:205)03-07 21:27:43.713: W/Ads(5189):  at com.google.ads.b.run(SourceFile:280)03-07 21:27:43.713: W/Ads(5189):  at java.lang.Thread.run(Thread.java:1027)03-07 21:27:43.733: W/dalvikvm(5189): JNI: DeleteGlobalRef(0xde6f0df7) failed to find entry (valid=0)03-07 21:27:43.733: W/dalvikvm(5189): JNI: DeleteGlobalRef(0xde6f0dd7) failed to find entry (valid=0)03-07 21:27:43.733: D/webviewglue(5189): nativeDestroy view: 0x46127803-07 21:27:43.733: I/Ads(5189): onFailedToReceiveAd(A network error occurred.)

2012-03-08 0comments 92hotness 0likes mikebai Read all
DotNET

ajax处理耗时事件,显示loading的方法

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm5.aspx.cs" Inherits="WebApplication1.WebForm5" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title></title>    <script language="javascript" type="text/javascript">        var xmlHttp;        //xmlHttpRequest        function createXMLHttpRequest()        {            if (window.ActiveXObject)                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); //IE            else if (window.XMLHttpRequest)                xmlHttp = new XMLHttpRequest(); //Firefox        }         function htmer_loading()        {            createXMLHttpRequest();            xmlHttp.onreadystatechange = function ()            {                if (xmlHttp.readyState == 4 && xmlHttp.status == 200)                //若响应完成,则显示htmer.asp中的内容                    document.getElementById("show").innerHTML = xmlHttp.responseText;                else                //若响应未完成,则显示Loading                    document.getElementById("show").innerHTML = "Loading......";            }            xmlHttp.open("GET", "Handler1.ashx", true);            xmlHttp.send(null);        }    </script></head><body>    <form id="form1" runat="server">    <div>        <input type="button" value="check ajax" onclick="htmer_loading()" />    </div>    <div id="show">    </div>    </form></body></html>   耗时请求页面处理Handler1.ashx     public class Handler1 : IHttpHandler    {         public void ProcessRequest(HttpContext context)        {            context.Response.ContentType = "text/plain";             Thread.Sleep(3000);             context.Response.Write("<Br/> test result");             context

2012-02-24 0comments 97hotness 0likes mikebai Read all
dev

android的PowerManager和PowerManager.WakeLock

保持android 屏幕常亮的方法 前言   学习android一段时间了,为了进一步了解android的应用是如何设计开发的,决定详细研究几个开源的android应用。从一些开源应用中吸收点东西,一边进行量的积累,一边探索android的学习研究方向。这里我首先选择了jwood的 Standup Timer 项目。本文将把研究的内容笔记整理,建立一个索引列表。 PowerManager.WakeLock   PowerManager.WakerLock是我分析Standup Timer源代码时发现的一个小知识点,Standup Timer 用WakeLock保证程序运行时保持手机屏幕的恒亮(程序虽小但也做得相当的细心,考虑的很周到)。PowerManager 和PowerManager.WakerLock7用于对Android设备的电源进行管理。   PowerManager:This class gives you control of the power state of the device.   PowerManager.WakeLock: lets you say that you need to have the device on.   Android中通过各种Lock锁对电源进行控制,需要注意的是加锁和解锁必须成对出现。先上一段Standup Timer里的代码然后进行说明。 private void acquireWakeLock() { if (wakeLock == null) { Logger.d("Acquiring wake lock"); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, this.getClass().getCanonicalName()); wakeLock.acquire(); } }private void releaseWakeLock() { if (wakeLock != null && wakeLock.isHeld()) { wakeLock.release(); wakeLock = null; } }acquireWakeLock()方法中获取了 SCREEN_DIM_WAKE_LOCK锁,该锁使 CPU 保持运转,屏幕保持亮度(可以变灰)。这个函数在Activity的 onResume中被调用。releaseWakeLock()方法则是释放该锁。它在Activity的 onPause中被调用。利用Activiy的生命周期,巧妙的让 acquire()和release()成对出现。 @Override protected void onResume() { super.onResume(); //获取锁,保持屏幕亮度 acquireWakeLock(); startTimer(); }

2012-02-23 0comments 98hotness 0likes mikebai Read all
dev

Android 9 patch 图片 (.9.png 格式图片) 的特点和制作

本文围绕 .9.png 格式图片讨论以下两个话题:  1. 该格式图片的特点  2. 制作方式    一 .9.png 格式的文件的特点    与传统的png 格式图片相比, 9.png 格式图片在图片四周有一圈一个像素点组成的边沿,该边沿用于对图片的可扩展区和内容显示区进行定义。     这种格式的图片在android 环境下具有自适应调节大小的能力。    (1)允许开发人员定义可扩展区域,当需要延伸图片以填充比图片本身更大区域时,可扩展区的内容被延展。    (2)允许开发人员定义内容显示区,用于显示文字或其他内容     如下图所示:     左侧和上方的黑线交叉的部分即可扩展区域     右侧和下方的黑线交叉的部分即内容显示区        二、 .9.png 图片的制作     android  sdk 的 tools 文件夹下提供了制作该格式图片的工具 draw9patch.bat           使用此工具打开任意图片之后,将鼠标置于图片上,主界面如下图所示:             被黑色覆盖的是不可编辑(锁住)的区域,周围的一圈一个像素的边沿是可编辑区域。        按住鼠标左键,在左侧和上方的边沿画出可扩展区    在右侧和下方画出内容显示区,结果如下所示:        完成绘制以后,选择file-> save ,即可保存为 .9.png 格式的文件,并在android 项目中使用。

2012-02-18 0comments 95hotness 0likes mikebai Read all
dev

kanjidict2数据说明

  <!-- Entry for Kanji: 亜 --><character>  <literal>亜</literal>   <codepoint>码表    <cp_value cp_type="ucs">4e9c</cp_value>Unicode 4.0    <cp_value cp_type="jis208">16-01</cp_value>JIS X 0208-1997 - kuten coding  </codepoint>   <radical>    <rad_value rad_type="classical">7</rad_value>classical - as recorded in the KangXi Zidian.    <rad_value rad_type="nelson_c">1</rad_value>nelson_c - as used in the Nelson "Modern Japanese-English  </radical>   <misc>    <grade>8</grade>1-6表示教育汉字(日本学校教学汉字),8常用汉字,9,10人名用汉字    <stroke_count>7</stroke_count>笔画数    <variant var_type="jis208">48-19</variant>    <freq>1509</freq>kanjidict rank中出现的频率    <jlpt>1</jlpt>Japanese Language Proficiency test level,1最难,4最简单,JLPT不要求的不出现该字段    <rad_name>のぎ</rad_name>    <rad_name>のぎへん</rad_name>  </misc>   <dic_number>在发表的字典和书刊中,该字出现的索引    <dic_ref dr_type="nelson_c">43</dic_ref>    <dic_ref dr_type="nelson_n">81</dic_ref>    <dic_ref dr_type="halpern_njecd">3540</dic_ref>    <dic_ref dr_type="halpern_kkld">2204</dic_ref>    <dic_ref dr_type="heisig">1809</dic_ref>    <dic_ref dr_type="gakken">1331</dic_ref>    <dic_ref dr_type="oneill_names">525</dic_ref>    <dic_ref dr_type="oneill_kk">1788</dic_ref>    <dic_ref dr_type="moro" m_vol="1" m_page="0525">272</dic_ref>    <dic_ref dr_type="henshall">997</dic_ref>    <dic_ref dr_type="sh_kk">1616</dic_ref>    <dic_ref dr_type="jf_cards">1032</dic_ref>    <dic_ref dr_type="tutt_cards">1092</dic_ref>    <dic_ref dr_type="kanji_in_context">1818</dic_ref>    <dic_ref dr_type="kodansha_compact">35</dic_ref>    <dic_ref dr_type="maniette">1827</dic_ref>  </dic_number>    <query_code>汉字笔画成图用    <q_code qc_type="skip">4-7-1</q_code>    <q_code qc_type="sh_desc">0a7.14</q_code>    <q_code qc_type="four_corner">1010.6</q_code>    <q_code qc_type="deroo">3273</q_code>  </query_code>    <reading_meaning>     <rmgroup>      <reading r_type="pinyin">ya4</reading>       <reading r_type="korean_r">a</reading>      <reading r_type="korean_h">아</reading>       <reading r_type="ja_on">ア</reading>      <reading r_type="ja_kun">つ.ぐ</reading>            <meaning>Asia</meaning>      <meaning>rank next</meaning>      <meaning>come after</meaning>      <meaning>-ous</meaning&g

2012-02-14 0comments 94hotness 0likes mikebai Read all
dev

SQL Server 2005数据库的排序规则

SQLSEVER2005中使用的排序规则是SQL_Latin1_General_CP1_CI_AS,而不是可以正确显示汉字的三种排序规则:Chinese_PRC_BIN,Chinese_PRC_CI_AS,Chinese_PRC_CS_AS 在将SQL Server 2005中将排序规则改成Chinese_PRC_CI_AS,问题解决。MS对排序规则的描述:在 Microsoft SQL Server 2000 中,字符串的物理存储由排序规则控制。序规则指定表示每个字符的位模式以及存储和比较字符所使用的规则。 也就是说,在SQL Server排序规则实际上就是字符编码。在查询分析器内执行下面语句,可以得到SQL Server支持的所有排序规则。 1.select * from ::fn_helpcollations()  排序规则名称由两部份构成,前半部份是指本排序规则所支持的字符集。如:Chinese_PRC_CS_AI_WS 。前半部份:指UNICODE字符集,Chinese_PRC_指针对大陆体字UNICODE的排序规则。排序规则的后半部份即后缀含义: _BIN 二进制排序_CI(CS) 是否区分大小写,CI不区分,CS区分_AI(AS) 是否区分重音,AI不区分,AS区分 _KI(KS) 是否区分假名类型,KI不区分,KS区分 _WI(WS) 是否区分宽度 WI不区分,WS区分  区分大小写:如果想让比较将大写字母和小写字母视为不等,请选择该选项。 区分重音:如果想让比较将重音和非重音字母视为不等,请选择该选项。如果选择该选项,比较还将重音不同的字母视为不等。 区分假名:如果想让比较将片假名和平假名日语音节视为不等,请选择该选项。 区分宽度:如果想让比较将半角字符和全角字符视为不等,请选择该选项 结论: 一:对于存在汉字显示??,同时又不想更改数据库上的排序规则,又想要正确显示出汉字的话,建议在设计时全部使用Unicode类型字段,也就是那些以N开头的字段类型,比如nChar,nVarchar,才可以正确显示汉字。 二:如果不想更改排序规则,又不想更改字段类型,那么就要更改SQL语句,对于所有的汉字,前面也要加上N才可以正确显示。具体的方法请参考下面两条语句: 查询:select * from tb_Cust where FirstName=N'汪'插入:insert tb_Cust(FirstName,LastName,Sex) values(N'汪',N'鑫昊',N'男')   ------------------------------------------ 第二篇 sql排序规则 如果要是区分大小写的话,就要改变数据库的排序规则。 1、查看系统中所支持的全部排序规则列表 SELECT * FROM ::fn_helpcollations() 2、查看当前系统的排序规则. SELECT SERVERPROPERTY('Collation') 3、改变数据库的排序规则(做ALTER之前,要中断所有用户对此数据库的访问) 语法:use mastergoALTER DATABASE 数据库名 COLLATE 排序规则名例子:use mastergoALTER DATABASE luwanzhufa COLLATE Chinese_PRC_CS_AS * 我查过。Chinese_PRC_CS_AS这个是简体中文。而且区分大小写的排序规则。 192 Japanese_BIN 二进制顺序、用于 932(日文)字符集。193 Japanese_CI_AS 字典顺序、不区分大小写、用于 932(日文)字符集。200 Japanese_CS_AS 字典顺序、区分大小写、用于 932(日文)字符集。198 Chinese_PRC_BIN 二进制顺序、用于 936(简体中文)字符集。199 Chinese_PRC_CI_AS 字典顺序、不区分大小写、用于 936(简体中文)字符集。203 Chinese_PRC_CS_AS 字典顺序、区分大小写、用于 936(简体中文)字符集。 如:ALTER DATABASE databaseCOLLATE Chinese_prc_ci_as   ---------------Windows 排序规则名称使用下表使排序规则设置与另一个 Windows 区域设置保持一致。 在"控制面板"的"区域设置"应用程序(Microsoft® Windows NT® 4.0、Microsoft Windows 98® 和 Microsoft Windows 95)或"区域选项"应用程序 (Microsoft Windows 2000) 中找到 Windows 区域设置名称,然后使用此表找到相应的排序规则指示器和代码页。 Windows 区域设置 LCID(区域设置 ID)排序规则指示器 代码页南非荷兰语 0xx436 Latin1_General 1252阿尔巴尼亚语 0x41C Albanian 1250阿拉伯语(沙特阿拉伯) 0x401 Arabic 1256阿拉伯语(伊拉克) 0x801 Arabic 1256阿拉伯语(埃及) 0xC01 Arabic 1256阿拉伯语(利比亚) 0x1001 Arabic 1256阿拉伯语(阿尔及利亚) 0x1401 Arabic 1256阿拉伯语(摩洛哥) 0x1801 Arabic 1256阿拉伯语(突尼斯) 0x1C01 Arabic 1256阿拉伯语(阿曼) 0x2001 Arabic 1256阿拉伯语(也门) 0x2401 Arabic 1256阿拉伯语(叙利亚) 0x2801 Arabic 1256阿拉伯语(约旦) 0x2C01 Arabic 1256阿拉伯语(黎巴嫩) 0x3001 Arabic 1256阿拉伯语(科威特) 0x3401 Arabic 1256阿拉伯语(阿拉伯联合酋长国) 0x3801 Arabic 1256阿拉伯语(巴林群岛) 0x3C01 Arabic 1256阿拉伯语(卡塔尔) 0x4001 Arabic 1256巴斯克语 0x42D Latin1_General 1252白俄罗斯语 0x423 Cyrillic_General 1251保加利亚语 0x402 Cyrillic_General 1251加泰罗尼亚语 0x403 Latin1_General 1252繁体中文(台湾) 0x30404 Chinese_Taiwan_Bopomofo 950繁体中文(台湾) 0x404 Chinese_Taiwan_Stroke 950简体中文(中华人民共和国) 0x804 Chinese_PRC 936简体中文(中华人民共和国) 0x20804 Chinese_PRC_Stroke 936中文(新加坡) 0x1004 Chinese_PRC 936克罗地亚语 0x41a Croatian 1250捷克语 0x405 Czech 1250丹麦语 0x406 Danish_Norwegian 1252荷兰语(标准) 0x413 Latin1_General 1252荷兰语(比利时) 0x813 Latin1_General 1252英语(美国) 0x409 Latin1_General 1252英语(英国) 0x809 Latin1_General 1252英语(加拿大) 0x1009 Latin1_General 1252英语(新西兰) 0x1409 Latin1_General 1252英语(澳大利亚) 0xC09 Latin1_General 1252英语(爱尔兰) 0x1809 Latin1_General 1252英语(南非) 0x1C09 Latin1_General 1252英语(加勒比) 0x2409 Latin1_General 1252英语(牙买加) 0x2009 Latin1_General 1252爱沙尼亚语 0x425 Estonian 1257法罗语 0x0438 Latin1_General 1252现代波斯语 0x429 Arabic 1256芬兰语 0x40B Finnish_Swedish 1252法语(标准) 0x40C

2012-02-13 0comments 93hotness 0likes mikebai Read all
DotNET

Microsoft Translator API语言code列表

http://www.microsofttranslator.com/dev/http://msdn.microsoft.com/en-us/library/ff512419.aspx Code Japanese English Chinese Simplified Chinese Traditional ar アラビア語 Arabic 阿拉伯语 阿拉伯文 bg ブルガリア語 Bulgarian 保加利亚语 保加利亞文 ca カタロニア語 Catalan 加泰隆语 卡達隆尼亞文 zh-CHS 簡体字中国語 Chinese Simplified 简体中文 簡體中文 zh-CHT 繁体字中国語 Chinese Traditional 繁体中文 繁體中文 cs チェコ語

2012-02-09 0comments 100hotness 0likes mikebai Read all
dev

android layout_weight讲解

在网上看了一些对Layout_weight的讲解,有些说的比较片面,只列举了一种情况,然后自己通过实验和一些比较好的文章总结了一下,特此记录下来,以备以后所用。Layout_weight是线性布局,也就是LinearLayout里面用到的,下面通过实验来看这个Layout_weight的特性。 1.当控件的属性android:layout_width="fill_parent"时,布局文件如下: Xml代码 <?xml version="1.0" encoding="utf-8"?>   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"       android:orientation="horizontal" android:layout_width="fill_parent"       android:layout_height="fill_parent">       <Button android:layout_width="fill_parent"           android:layout_height="wrap_content" android:layout_weight="1"           android:text="Button1" />       <Button android:layout_width="fill_parent"           android:layout_height="wrap_content" android:layout_weight="2"           android:text="Button2" />   </LinearLayout>   <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="Button1" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_conten

2012-02-04 0comments 94hotness 0likes mikebai Read all
dev

ZipFile.getEntry 无法获得内容

最近android上做660多MB的zip文件中解压缩wav文件 ZipEntry zipEntry = zipFile.getEntry(entryName);发现上面的方法始终null但文件时的确存在的,于是在市场上下载各种zipapp 打开zip文件后,发现里面部分文件夹丢失费解,于是上网咕咕噜http://stackoverflow.com/questions/8653283/reading-a-huge-zip-file-in-java-out-of-memory-error It is very unlikley that you get an out of memory exception because of processing a ZIP file. The Java classes ZipFile and ZipEntry don't contain anything that could possibly fill up 613 MB of memory. What could exhaust your memory is to keep the decompressed files of the ZIP archive in memory, or - even worse - keeping them as an XML DOM, which is very memory intensive. Switching to another ZIP library will hardly help. Instead, you should look into changing your code so that it processes the ZIP archive and the contained files like streams and only keeps a limited part of each file in memory at a time. BTW: I would be nice if you could provide more information about the huge ZIP files (do they contain many small files or few large files?) and about what you do with each ZIP entry. Update: Thanks for the additional information. It looks like you keep the contents of the ZIP file in memory (although it somewhat depends on the implementation of the S3Object class, which I don't know). It's probably best to implement some sort of batching as you propose yourself. You could for example add up the decompressed size of each ZIP entry and upload the files every time the total size exceeds 100 MB. -------------------------------- 上面的是java上的原因,android 上不知道是不是也是这个原因.目前没找到解决方案.

2012-02-03 0comments 95hotness 0likes mikebai Read all
dev

Java编码的那些事儿

Java编码 Unicode是全球标准字符集,是Java所为String采用的编码方式,任何字符用2个字节表示。String实例中保存有一个char[]字符数组。string.getByte()方法可以获得到这个字符串实例在指定编码下的字节数组,注意的是不带参数的getByte方法使用OS默认的字符集,比如GB2312(简体中文)。所以要得到Unicode下的字节数组,需要这样:string.getBytes(“unicode”)(此处注意见下文)。如果使用new String(byte[], Charset)构造,可以将已知编码的字节数组重新拼成一个String实例,即用指定的Charset去组合字节为Unicode字符罢了。同理,不带Charset的String构造使用OS默认字符集。 因此,得到UTF-8的字节数组,按以下步骤: 1 2 3 4 String str = "梦"; byte[] bytes = str.getBytes("UTF-8"); "使用UTF-8解码字符串得到的UTF-8字节数组" String str2 = new String(bytes, "utf8"); "按照当初被解码的方式(utf8)重新组成Java String类" str.equals(str2) == true; "使用大小写不同的编码写法,来区别不同API中参数代表的意义" 所以,str = new String(str.getBytes(Charset), Charset) 什么都没有做,除了新建了个String对象。 但是如果你要获取unicode的字节数组,却有非常多的选择,而且很容易出错。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 void echoBytesTest() { String s = "梦"; echoBytes(s, "Unicode"); echoBytes(s, "UnicodeBig"); echoBytes(s, "UnicodeLittle"); echoBytes(s, "UnicodeBigUnmarked"); echoBytes(s, "UnicodeLittleUnmarked"); echoBytes(s, "UTF-16"); echoBytes(s, "UTF-16BE"); echoBytes(s,

2012-01-31 0comments 99hotness 0likes mikebai Read all
1…3031323334…62

Recent Posts

  • c# winform适配高dpi
  • com.microsoft.sqlserver.jdbc.SQLServerException “trustServerCertificate”属性设置为“false”,但驱动程序无法使用安全套接字层 (SSL) 加密与 SQL Server建立安全连接
  • java -cp 用法介绍
  • HTML 容器元素
  • MVC的cshtml的介绍

Recent Comments

No comments to show.

COPYRIGHT © 2025 mikebai.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang