2011年6月16日 星期四

Android NDK in Eclipse on Windows 7

再精簡一下流程
1. Download NDK for Windows並解開到想放的位置(Ex. C:\Android\android-ndk-r5c)
2. Windows環境要多裝一個Cygwin(Ex. C:\cygwin),下面兩個連結皆可參考
http://cheng-min-i-taiwan.blogspot.com/2010/06/android-ndk-hellojni.html
http://www.61ic.com/Mobile/Android/201105/34543.html
我是參考第一個連結的圖示,安裝套件在Devel分類的
gcc: C compiler upgrade helper
gcc-core: C compiler
gcc-g++: C++ compiler
gcc-mingw-core: Mingw32 support headers and libraries for GCC
gcc-mingw-g++: Mingw32 support headers and libraries for GCC C
make: The GNU version of the 'make' utility
mingw-runtime: MinGW Runtime

執行一下Cygwin.bat, home底下,使用者名稱目錄會被建立,然後出現.bash_profile,編輯這個檔案並存檔


PATH=/cygdrive/C/Android/android-ndk-r5c:${PATH}
export PATH


3. Eclipse-Project-Properties-Builders新增一個External Tool Program到第一個位置,內容就不贅述,重點在於Main Tab的設定,以我的環境為例
Location: C:\cygwin\bin\bash.exe
Working Directory: C:\cygwin\bin
Argument:
--login -c "cd  /cygdrive/D/work/study/Android/workspace/tryNDK/${project_name}/jni && ndk-build"

另外, Android Project Build Target必須是GoogleAPIs

2011年6月15日 星期三

android.app.Application

在Study NDK的章節裡,看到sample用到Application,之前沒看過這個東西,基本上,


http://developer.android.com/reference/android/app/Application.html

給的定義如下


Base class for those who need to maintain global application state. You can provide your own implementation by specifying its name in your AndroidManifest.xml's tag, which will cause that class to be instantiated for you when the process for your application/package is created.


其實, application的角色可以從AndroidManifest.xml裡的結構就可以看出來


manifest
---application
------activity


activity是包在application裡面的, 只是我們只把application當作一個殼, 在這個sample是將這個殼加了一個儲藏室,只要多定義


android:name=".UA2EFindEdgesApp"


 然後實做


public class UA2EFindEdgesApp extends Application


這樣在整個application所包圍的區域,都可以利用 


UA2EFindEdgesApp app = (UA2EFindEdgesApp) getApplication();


取用這個application所增加的功能,以書上的例子是藉此存取系統共用的Bitmap






2011年6月10日 星期五

終於在Windows7裝好Notes Client

其實會覺得問題不在Windows7,但是之前在XP下怎麼裝都ok,一樣的手法在Windows7卻不行,難怪會認為是Windows7的問題

之前的裝法是,我把可以執行環境(WindowsXP)的data目錄直接copy到Windows7,然後在Windows7裝完Notes Client後,將資料目錄直接指到這個目錄,接下來就切換ID

發生的問題是SMTP有問題,去查google,得到的答案直指Vista/Windows7沒有內建SMTP服務,於是我裝了SMTP server來轉發mail,就這樣使用了幾年之久

5月底換了新筆電,還是秉持著自給自足,不找MIS的學習精神(這是不好的,沒本事請不要學我),想方法處理,裝了好幾版Notes Client,都出現CoreEmailClasses有問題,這是在不copy data目錄的情況下,如果使用copy其他環境的data目錄,則會出現之前SMTP的問題

這下,我明白了,一定是我的data目錄並沒建好,一直都有瑕疵,有可能是版本或是OS有差異,所以舊有data目錄不能再用(甚至這種裝法是不應該的),應該想辦法解決為什麼會出現,"Illegal circular USE: CoreEmailClasses",畢竟看得到郵件目錄,只是打開才有問題,可能原因如下

https://www-304.ibm.com/support/docview.wss?uid=swg21089915&wv=1

但要怎麼修復,目前看起來是好的,但是我不確定是哪一個環節做對了

1. 我在設定過程中,第一次有設定Domino Server,幾年前設定有問題,後來就每次都關掉,這次設定了,也抓到了,接下來還直接問我ID File,裝完後,收發信就沒有CoreEmailClasses的問題,但是出現Server信件會重複出現,除非我把狀態改成Read,只要是Unread的,會一直自我複製,而且Send Mail到其他外部信箱,例如Gmail,會收不到

2. 猜想是Local和Server信箱同步問題,於是去查了Replication的用法,follow指示

http://www.ibm.com/developerworks/cn/lotus/notes-replication/index.html

目前頭好壯壯,再用一陣子看看

基本上,對Notes Server端做了哪些事並不清楚,但本著只不過是個收發mail的tool,即使是Notes Ap,也不過是藉著mail通道,做出Client-Server架構的資料庫應用,能用基本系統邏輯來處理的話,還是自己試試看,對邏輯推理有幫助

2011年4月18日 星期一

工作日誌很重要

無論如何,把WeeklyReport當工作日誌寫,絕對是有幫助的
不管有沒有人看,用自己的思路,整理自己的工作,用最省時的方式記錄下來
隨時都可以更新
我只要看到Weekly Report是每周更新一次的,就知道只是應付上面要求,那真的寫了對自己是浪費時間
隨時更新才能隨時做計畫,檢討並調整方向
一定會有幫助
But it still depend on you
I have no right to force you
It's just for your own good

2011年4月15日 星期五

Important Notes for Android Bound Service



There are three ways you can define the interface:
Extending the Binder class
If your service is private to your own application and runs in the same process as the client (which is common), you should create your interface by extending the Binderclass and returning an instance of it from onBind(). The client receives the Binderand can use it to directly access public methods available in either the Binderimplementation or even the Service.
This is the preferred technique when your service is merely a background worker for your own application. The only reason you would not create your interface this way is because your service is used by other applications or across separate processes.
Using a Messenger
If you need your interface to work across different processes, you can create an interface for the service with a Messenger. In this manner, the service defines a Handler that responds to different types of Message objects. This Handler is the basis for a Messenger that can then share an IBinder with the client, allowing the client to send commands to the service using Message objects. Additionally, the client can define aMessenger of its own so the service can send messages back.
This is the simplest way to perform interprocess communication (IPC), because the Messenger queues all requests into a single thread so that you don't have to design your service to be thread-safe.
Using AIDL
AIDL (Android Interface Definition Language) performs all the work to decompose objects into primitives that the operating system can understand and marshall them across processes to perform IPC. The previous technique, using a Messenger, is actually based on AIDL as its underlying structure. As mentioned above, the Messenger creates a queue of all the client requests in a single thread, so the service receives requests one at a time. If, however, you want your service to handle multiple requests simultaneously, then you can use AIDL directly. In this case, your service must be capable of multi-threading and be built thread-safe.
To use AIDL directly, you must create an .aidl file that defines the programming interface. The Android SDK tools use this file to generate an abstract class that implements the interface and handles IPC, which you can then extend within your service.
Note: Most applications should not use AIDL to create a bound service, because it may require multithreading capabilities and can result in a more complicated implementation. As such, AIDL is not suitable for most applications and this document does not discuss how to use it for your service. If you're certain that you need to use AIDL directly, see the AIDL document.

2011年4月14日 星期四

Scrollable TabWidget in Android

I practiced the Tab Layout Tutorial by

http://developer.android.com/resources/tutorials/views/hello-tabwidget.html

and realized that I need to scroll the TabWidget. After Goofling "android scroll tabwidget",
thanks to bscarl88

http://androidforums.com/application-development/118108-scrollable-tabs.html

I could not successfully paste the xml here, so I use "[" and "]" instead of "<" and ">"
 

Originally is


                    [TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" /]


Now is


[HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"]    
                    [TabWidget
        android:orientation="horizontal"
           android:id="@android:id/tabs"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content" /]
        [/HorizontalScrollView]  

2011年4月6日 星期三

上帝的安排真是奇妙, What's Next?

本以為我換了三個全然不相干的產業和職能, 但現在回頭檢視, 竟是環環相扣


中光電: 背光板色彩, 光學檢測程式(VB)
宇太新: ERP 物管系統(VB), EAI(Java, Software Engineering)
崴強:     DSC 影像色彩, MFP DSP/影像色彩, Qt/QML, RTOS(C)/Linux(C)/Android(Java)


在崴強用到了前兩個工作的技術觀念, 下一個工作會發生什麼事呢?