Saturday, January 26, 2013

AdMob 中 AdView 在 Proguard 之下的 "Proguard returned with error code 1"

多手升級一下 App 中的 Proguard version 同 AdMob SDK 立即出了:


Proguard returned with error code 1. See console
Note: there were 160 duplicate class definitions.
Warning: com.google.ads.m: can't find referenced class com.google.ads.internal.state.AdState
Warning: com.google.ads.m: can't find referenced class com.google.ads.internal.state.AdState
You should check if you need to specify additional program jars.
Warning: there were 2 unresolved references to classes or interfaces.
 You may need to specify additional library jars (using '-libraryjars').

先在 Project -> Build Path -> Export 中手動加入了
GoogleAdMobAdsSdk-6.2.1.jar
但那Error老在
又修改了一下 proguard-project.txt:
加入了:


-keepattributes *Annotation*
-keep public class com.google.ads.** {*;}
-libraryjars /libs/GoogleAdMobAdsSdk-6.2.1.jar

都无功而返:
只好學一下AdView 中的example 加入一些

-dontpreverify -repackageclasses '
-allowaccessmodification 
-optimizations !code/simplification/arithmetic


-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}


但是............
所以話AdMob 是 Google API 中最失敗的一個
次次要Update 都要花費一些時間.
最後只好問問全能的Google.


This problem started with AdMob SDK 6.1.0 and 6.2.1 (for Android). To fix the error, add this to your proguard.cfg file:
中文是叫大家加下會的一句在 proguard.cfg:

-dontwarn com.google.ads.**



Case Close.



Wednesday, January 23, 2013

Hong Kong ID Formula (HKID Number Check Digit)

此文之中文版
http://computerterminal.blogspot.hk/2005/11/hkid-calculation.html


I found out form the Google Analystic that 1/8 of the visitors to this site is to the post HKID Calculation and 1/3 of the visitors are from Russia(!!!) and USA. So i decide to write that post in English for them.

HK ID number starts from Two English Letters plus 6 digits and end with a check digit in bracket
for example: AB987654(3)

Validate the HKID by the following steps:


1) Replace the leading English alphabet with numberic value following the rules below:

Space = 36  A = 10    B = 11   C = 12   D = 13  E = 14    F = 15

G = 16    H = 17   I = 18     J = 19   K = 20    L = 21M = 22    N = 23  O = 24   P = 25   Q = 26    R = 27S = 28    T = 29   U = 30   V = 31   W = 32   X = 33Y = 34     Z = 35

2) Weighted Total 
Calculation 
   A)If double english alphabet digit,e.g. AB987654(3):
           Total = 1st Digit x9 + 2nd Digit x8 + 3rd Digit x7 + 4th Digit x6 + 5th Digit x5 + 6th Digit x4 + 7th Digit x3 +8th Digit x2

   B) Else if single english alphabet digit,e.g. E364912(5):
           E364912(5) = (Space)E364912(5)
           Total = 36 x 9 + 1st Digit x8 + 2nd Digit x7 + 3rd Digit x6 + 4th Digit x5 + 5th Digit x4 + 6th Digit x3 + 7th Digit x2 

3) CheckDigit Calculation

Remaining= Total modulo 11 

IF
a)Remaning = 0:
   CheckDigit = 0

b)Remaning = 1:
   CheckDigit = A

c)Remaning = [2-10]:
   CheckDigit = 11 - Remaining


Example:
HKID:E364912(5)
(PS:E is equal to 14 according to step 1)

324 + 14x8 + 3x7 + 6x6 + 4x5 + 9x4 + 1x3 + 2x2 = 556

556 % 11 = 68

11 - 6 = 5

So E364912(5) is a Valid HKID


Wednesday, March 28, 2012

Android :: Hide Virtual Keyboard on App Start ( 隱藏鍵盤)

最近在做一個睇星坐APP, 一開始有一個 edittext, 但一當 load activity 時就該edittext 就立即on focus 彈出 virtual keyboard
google 一下, 只要在Activity::OnCreate 中加入以下 code 即可 !!!


// hidden keyboard
this.getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

Tuesday, February 07, 2012

Set up DfpAdView/AdView of admob

教學有很多, 但大多十分多肺話, 所以我的十分精簡:

1) Reg On Admob site to get the Publisher ID -  a14exxxxxxxxxx

2) Mainfest.xml:
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <activity
            android:name="com.google.ads.AdActivity"            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

3) Add a LinearLayout called ad_layout to the Activity "XML" file that u want to show the ad.

4a) Add the code to the correspondence Activity "JAVA Code" file
   
    ------- Field -------
     private DfpAdView mAdView;

      I----- onCreate ------
      final LinearLayout adRow = (LinearLayout) findViewById(R.id.ad_layout);
mAdView = new DfpAdView(this, AdSize.SMART_BANNER, "a14exxxxxxxxxx");
adRow.addView(mAdView);
mAdView.loadAd(new AdRequest());

4b) Change DfpAdView to AdView, if u want AdView

5) Override onDestory
     @Override
protected void onDestroy() {
if (mAdView != null) {
mAdView.removeAllViews();
mAdView.destroy();
}
super.onDestroy();
}

6) Run Test !!!!

PS: Add DfpInterstitialAd Later
 

Saturday, January 27, 2007

Hafnium Vally ?

Intel and IBM announces a research result tothe use of alloy of hafnium to replace the silicon dioxide can makes Morrow's Law to be valid in the future.

New York Time

Sunday, January 21, 2007

Wednesday, January 17, 2007

Proxy + 代理猎手

我现在是proxy switcher 跟 代理猎手一起用,proxy switcher 有个功能是自动下载代理服务器网站的代理列表,找到后在全部拿到代理猎手上verify,看哪个连到gindis的比较快。。。具体操作嘛。。。。

proxy switcher
Actions-->Download Proxy Lists,等待几分钟,程序如果开始testing 那些代理的话你把他给stop掉,这时你应该可以在左边
NEW里看到一些刚刚下载的代理,点那个new的文件夹,全选右边的代理,然后File-->export to text file-->命名


代理猎手
System-->Change Option 出来一个option,按中间那个Verification Data Option tab, 选择下面的Add
会出现一个窗口
Name:随便
URL:你要verify 的网址,http://www.gindis.com, 这个填完后按旁边的get, 新窗口弹出再按get一次,这时你会在那个新窗口收到一些数据,随便copy 一下army commander 之类的当你的key word,然后按ok,接着回到你之前的Verification Data Option tab, 选择刚刚你才加的verification,然后按下面的use。这是为了以后测试你那些代理服务器连到这个网址后能不能在找到这个keyword,找到 的速度越快代表你的代理越快(当然可能连接gindis快的,连接论坛就慢了,有时根本不能连)

接下来去代理猎手主窗口,点Results-->import-->之前找到的代理,加完后点中间那个Result tab,按右边的verify all,等几分钟,good就是可以用的代理,你点Timing 可以从最快到最慢排序

回到proxy switcher
选择左边的proxyswitcher 文件夹,把刚刚那些good的代理加进去,剩下的就一个个试,看哪个速度快

Monday, January 15, 2007

Next Generation of Fortan -- Fortress

Sun released Fortress as a replacement of well know scientific purpose language -- Fortran.
Fortress is target on JVM 1.5.

The most natural different between it and Java is that it assume that a process should be run in parallel instead of single-threaded. It also means to target to high-performance computing area.

Tuesday, January 09, 2007

iPhone come out from Jobs's packet

In today Macworld San Franciso 2007, Jobs took a new iPod from his packet !!!

Ohhhhhhh~~ wait that is not iPod !!!!


~~ iPhone ~~

The details released were:
  1. 3.5-inch widescreen display

  2. 2.0 Megapixel camer

  3. 8GB /4GB storage

  4. Bluetooth with EDR

  5. WiFi

  6. quadband GSM radio with EDGE.
7. It will be availiable in June for $499 for 4GB and $599 for 8GB
iPhone Offical Site


Sunday, December 03, 2006

Quake 3 's InvSqrt

float InvSqrt (float x){
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i >> 1);
x = *(float*)&i;
x = x*(1.5f - xhalf*x*x);
return x;
}

Math explanation here (PDF)

Thursday, November 23, 2006

Send File !?!? 沒有困難 ~~~

Ha, I find the simple input is just a PDF file, so to check the programe is correct or not, just remain the output to .bin file..

Source Code Later !!

Sunday, November 12, 2006

Download from You Tube

"View Page Source” and do a text search for

player2.swf?video_id=

For example the internal prolonged video identification code may be:

b4Knsa7kBPE&l=48&t=OEgsToPDskI3D6CVWsTxEa4BzcTHKXc7
&s=E04B5F8107785BA4:8A51374783A7BCE6

Keep in mind that the code between “&t=” and “&s=” may be session-sensitive and changed every time the video is accessed.

To save the video, the URL path format is

http://www.youtube.com/get_video?video_id=prolonged_video_identification_code

Set the range of SQL result

SQL LIMIT

如果在某項查詢結果中,我們想要的僅是其中一部份時,可以使用 LIMIT 來限制資料被讀取的筆數。
例如,找出座號最前面的五位學生姓名:

SELECT realname FROM student ORDER BY num LIMIT 0, 5

在此例中,LIMIT 後方的 0 代表「從第 0 筆資料開始」,5 表示「取出 5 筆資料」。

Monday, October 30, 2006

Here's some code for blurring an image:

float[] kernelData = new float[9];
for (int i = 0; i < kernelData.length; i++)
{
kernelData[i] = 0.15f;
}
ConvolveOp blur = new ConvolveOp(new Kernel(3, 3, kernelData));
BufferedImage blurryImage = new BufferedImage(w, h, w, h,
BufferedImage.TYPE_INT_ARGB);
blurryImage.createGraphics().drawImage(imageToBlur, blur, 0, 2);