星期四, 9月 13, 2012

Android 開發過程中的 "Dirty hack"

最近一直在讀一些Open source的程式碼,
為了實現我在未來所要完成的一些工作和想法,
有時候很佩服這些願意把程式碼分享給其他人的程式設計師,
至少在目前我還很小氣的不想把程式碼分享給其他人Orz,

應該很多人和我一樣,覺得讀別人的程式碼很痛苦,
但是讀這些程式碼真的會讓寫程式的功力和邏輯想法變得不一樣,
況且這些願意分享的Open source專案的作者,
也都有一定的實力與經驗,才有勇氣把自己的程式碼放出來,
很難想像如果我把自己的程式碼攤在大家面前時那是什麼感覺,
可能一堆人"幹譙"說寫這麼爛也敢拿出來,
或者根本就沒人對我的程式碼有興趣XD

我在這份開放原始碼的專案中,
其中一行註解看到了Android開發者的無奈XD


作者為了HTC Flyer做了一些客製化的程式碼,
然後在程式碼上方註解 "//dirty hack for the HTC Flyer"
看起來是HTC Flyer在觸控事件發生時所傳回的MotionEvent上,
沒有提供足夠的觸控資訊,通常裝置可以粗略判斷觸控的物質是手指、觸控筆或其他,
並將此資訊提供給程式進行接下來的邏輯運算,
顯然HTC Flyer的感觸Sensor沒有把這個資料正確的回傳,
最後只能作者自己想辦法~

其實我一開始並不知道Dirty hack實際的意義是什麼,
於是上網Google一下在這個簡體網站舉了例子,
做了精闢的字義說明!



想必看完之後會發現,
原來許多在Android開發過程所寫的程式碼就是在做Dirty hack,
因為Android裝置廠商眾多,
實在沒辦法確認所寫的Code真的能在所有裝置上面順利運行,
有時候真的要等到有使用者在評分版上抱怨的時候,
開發者才會知道,原來這款手機會有問題,
但即使知道了有問題,如果開發者手邊沒有這款手機,
那開發者有80%的機率還是沒辦法知道發生問題的原因,
因為別款手機都沒問題阿ˊ__ˋ

如果手邊有發生問題的手機,開發者就可以為這些手機量身訂做解決方案,
也就是上面說到的"Dirty hack" ~ ~a

在寫Navier HUD時就有發生部分手機在利用Android API取得GPS座標時,
竟不會同時回傳速度,
遇到這種時候只好自己利用兩點距離和時間自己算速度才有辦法解決了,
下次我一定會記得在這些Code上面註解這些是"Dirty hack" XDD

所以各位App愛用者,
要購買App前一定要先確認是否在您的手機上會有問題,
當遇到App某些功能在您的手機上運作不正常時,
如果那個App是免費的,請記得評分時手下留情Orz
並記得寫信告知作者您的手機型號和問題!
請體諒Android App的作者沒辦法購買所有的Android裝置來測試呀~



12 則留言:

sigma Liao 提到...

換個想法,建議版主可以做一個免費的 app 讓人下載,裡面就一些基本的 Andorid 功能,讓大家測試自己的手機是否符合正常的程式功能或者需不需要 dirty hack ,這樣大家就可以知道該買哪種手機哩。

Shang-Chun Lu 提到...

是的我也是這麼想,所以我也提供了免費版,基本上使用者若買了付費版不合用,只要跟我說我也會直接退款給他

匿名 提到...

What's Happening i am new to this, I stumbled upon this I've found It positively helpful and it has aided me out loads.
I hope to give a contribution & assist different customers like its helped me.
Good job.

Also visit my website Working Sharecash Downloader 2012

匿名 提到...

I quite like reading through an article that can make men and women think.
Also, thanks for allowing for me to comment!


Also visit my webpage ... all materials cheat for cityville

匿名 提到...

Aw, this was an extremely good post. Finding the time and actual
effort to produce a top notch article… but what can I say… I procrastinate
a whole lot and never seem to get nearly anything done.


Here is my homepage: car town hack

匿名 提到...

I like the valuable info you provide in your articles.
I will bookmark your blog and check again here regularly.
I'm quite certain I will learn lots of new stuff right here! Good luck for the next!

my webpage :: Sharecash Downloader 2011

匿名 提到...

Undeniably imagine that that you said. Your favorite
reason appeared to be at the net the simplest thing to remember
of. I say to you, I certainly get annoyed while other
people think about concerns that they plainly don't understand about. You controlled to hit the nail upon the top and also outlined out the entire thing without having side-effects , other people could take a signal. Will likely be back to get more. Thanks

My site: Watch TV Series Online

匿名 提到...

I always used to read post in news papers but now as I am a
user of net thus from now I am using net for articles,
thanks to web.

Look at my web page; minecraft for free

匿名 提到...

Nice post. I was checking constantly this blog and I am impressed!

Extremely helpful info particularly the last part :) I care for such information
a lot. I was looking for this certain information for a very long time.
Thank you and best of luck.

Also visit my blog; dragonvale pc game download

匿名 提到...

Hi there, You have done an incredible job.
I'll certainly digg it and personally recommend to my friends. I am confident they will be benefited from this web site.

Look into my homepage - town cheats car

匿名 提到...

Wow, wonderful blog layout! How long have you been blogging for?
you make blogging look easy. The overall look of your website
is excellent, let alone the content!

Check out my website How to get free Minecraft

匿名 提到...

I visited multiple web pages but the audio quality for audio songs present
at this web site is in fact superb.

Also visit my blog :: hack a twitter