2012年7月30日 星期一

A New Way to Share/Connected each other : Heyzap


   玩社群遊戲最怕沒有朋友,以及不知道有什麼最新的好玩,Heyzap創造另一種專屬於遊戲的社群平台,透過check in的方式來告知玩家哪款新遊戲好玩與否;其實我媽就是屬於這類型的玩家,聽說開心水族箱為了彼此互助,甚至創辦社團作為溝通的管道(而且還不少人做這類似的事情),趕快出中文版滿足我媽吧!

Reference :



2012年6月12日 星期二

[Android] AsyncTask vs Handler vs Thread

起源:


Android裡面如何使用multi-thread,如果照需求去搜尋文件將得到三種物件:
  1. AsyncTask
  2. Handler
  3. Thread 
這 AsyncTask 和Thread共同的地方就是會開啟另一個Thread運作

而AsyncTask和Handler簡化了Thread與UIThread互動,這表示單純用Thread會需要自己實作Runnable然後塞進去Activity.runOnUiThread(Runnable)

而AsyncTask和Handler的差別在於AsyncTask只要實作好callback interface就可以與UI元件互動,而Handler要自己sendMessage/handleMessage

參考資料:



2012年5月28日 星期一

[Android] Compatible Solution on Android

0. Brief


  We always face the problem of compatible problem on Mobile Development. include the screen resolution, hardware spec, API behavior, memory size .... etc. that trigger me to find the answer on the most popular platform - Android.

1. Client 

1.1 Filter on Market 

http://pads162.cs.nthu.edu.tw/guide/appendix/market-filters.html

You can provide the limitation of resolution , hardware and sdk version ... etc

1.2 Backward Compatibility for Applications

http://developer.android.com/resources/articles/backward-compatibility.html

Use the java technical like Reflection or Wrapper


2. Standard on Device 

Android make a document about the hardware ability and the feature in each version

http://source.android.com/compatibility/downloads.html

and also provide the tool like TCK 

http://source.android.com/compatibility/cts-intro.html

the scope is show as follows:


AreaDescription
Signature testsFor each Android release, there are XML files describing the signatures of all public APIs contained in the release. The CTS contains a utility to check those API signatures against the APIs available on the device. The results from signature checking are recorded in the test result XML file.
Platform API TestsTest the platform (core libraries and Android Application Framework) APIs as documented in the SDK Class Index to ensure API correctness, including correct class, attribute and method signatures, correct method behavior, and negative tests to ensure expected behavior for incorrect parameter handling.
Dalvik VM TestsThe tests focus on testing the Dalvik VM
Platform Data ModelThe CTS tests the core platform data model as exposed to application developers through content providers, as documented in the SDK android.providerpackage: contacts, browser, settings, etc.
Platform IntentsThe CTS tests the core platform intents, as documented in the SDK Available Intents.
Platform PermissionsThe CTS tests the core platform permissions, as documented in the SDK Available Permissions.
Platform ResourcesThe CTS tests for correct handling of the core platform resource types, as documented in the SDK Available Resource Types. This includes tests for: simple values, drawables, nine-patch, animations, layouts, styles and themes, and loading alternate resources.



3. Other 

3.1 The Compatible problem on Android 3.x

Android 3.0 should compatible with Android 2.x and 1.x. the solution is Android Compatibility Package (it's a jar including all of extension on Android 3.x )

http://blog.chinatimes.com/tomsun/archive/2011/03/08/621087.html

2012年5月23日 星期三

[Android] ProxyView for XML Layout

    發Android的時候會盡量不破壞MVC的架構,所以對於Layout的定義能盡量寫xml就寫xml,但有時候還是會需要寫code的方式修改view的數值。 但如果想要擁有xml定義的好處,同時擁有動態更動數值的功能時,有一下幾種方式

一、放棄xml,完全用code去長View再addView

二、利用以下介紹proxy的方式

    以一個LinearLayout來說,裡面可能包含(1)TextView、(2)ImageView,而需要控制的程式邏輯變成 TextView.setText(String)以及ImageView.setImage(Bitmap)。

[test1.xml]

<> TODO </> 

    我們可以先把它定義成test1.xml,在src裡面建立一個ProxyView extends ViewGroup 當作中介容器。在constructor利用LayoutInflator.inflate(R.layout.test1)拿到該View並且this.addView(View)這樣xml裡面定義的view就加到自己的child。

[ProxyView]
context.getLayoutInflator().inflate(R.layout.test1,this);
this.textview = (TextView)context.findViewById(R.id.text1);
this.imageview = (ImageView)context.findViewById(R.id.image1);

    就可以在主程式加入這個ProxyView

[Activiy]
this.addView(new ProxyView(this));

    這時候要注意兩件事情:
    (1)ViewGroup default不會呼叫child的onDraw(),除非你呼叫 this.setWillNotDraw(false);
    (2)ViewGroup的onLayout必須正確實作,不然就是黑畫面
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) {
        for(int i = 0 ; i < getChildCount() ; i++){
             getChildAt(i).layout(l, t, r, b); }
       }

參考資料: 

    http://stackoverflow.com/questions/4448779/how-to-inflate-xml-layout-file-correctly-inside-custom-viewgroup

2012年5月17日 星期四

[ANDROID] Customized Seekbar

最近搞一套架構讓J2ME的遊戲邏輯能夠和Android的UI元件互動(細節未來再說明),在實做一系列遊戲的UI在Android平台上時需要客製化SeekBar,於是找到這篇文章 http://www.mokasocial.com/2011/02/create-a-custom-styled-ui-slider-seekbar-in-android/


但該文章實作內容有用到9-patch的東西,第一次碰到還真的不知從何下手,在ANDROID_SDK/tools/draw9patch.bat找到執行檔,並且編輯png來設定邊界範圍,怎麼設定都不是合法的9-patch格式 最後直接到網站上找範例 http://android10.org/index.php/articlesother/279-draw-9-patch-tutorial


可以在裡面download他們的範例9-patch檔,大概可以了解什麼才是合法的9-patch格式。