2011年5月26日 星期四

[Android] Failed to install apk on device: timeout

I got error message as below:


[2011-05-26 15:03:37] Android Launch!
[2011-05-26 15:03:37] adb is running normally.
[2011-05-26 15:03:37] Performing com.test.myActivityactivity launch
[2011-05-26 15:03:37] Automatic Target Mode: using device '10005231b7a7'
[2011-05-26 15:03:37] Uploading myActivity.apk onto device '10005231b7a7'
[2011-05-26 15:03:46] Failed to install myActivity.apk on device '10005231b7a7': timeout 
[2011-05-26 15:03:46] Launch canceled!


This is cause by insufficient time out limit in eclipse default setting.
You can change the limit at Window -> Preference -> Android -> DDMS

Monitor memory usage in Java


Use the code to get information of memory usage at runtime.
Runtime runtime = Runtime.getRuntime();long maxMemory = runtime.maxMemory();long allocatedMemory = runtime.totalMemory();long freeMemory = runtime.freeMemory();

Reference: http://stackoverflow.com/questions/74674/how-to-do-i-check-cpu-and-memory-usage-in-java

2011年5月6日 星期五

Git error: am - trailing whitespace

If origin file have trailing whitespace but new one doesn't.

You'll meet the error 'trailing whitespace' when you try to apply merge patch.

Use the comman git am --whitespace=fix <patch file name> to work it out.

It'll ignore all confict by trailing whitespace and do not merge those line.

Git: undo commit

You can undo previous commit without remove modified after commit.

git reset --soft HEAD~1

Or undo previous commit with remove modified after commit.

git reset --hard HEAD~1




You can remove your modification to lastest commit.

git reset --hard HEAD


2011年5月2日 星期一

[Android] GestureDetector: sigle finger touch event sequence

If your finger tapping on tab, it'll trigger event in turn:
  • OnTouch  (finger down on tab)
  • OnTouchEvent
  • OnDown
  • OnTouch  (finger lift off tab)
  • OnTouchEvent
  • OnSingleTapUp
  • OnSingleTapConfirmed   (event by OnDoubleTapListener)

If your finger long press on tab, it'll trigger event in turn:
  • OnTouch  (finger down on tab)
  • OnTouchEvent
  • OnDown
  • OnLongPress
  • OnTouch  (finger lift off tab)
  • OnTouchEvent

If your finger double-click on tab, it'll trigger event in turn:
  • OnTouch  (finger down on tab first time)
  • OnTouchEvent
  • OnDown
  • OnTouch  (finger lift off tab)
  • OnTouchEvent
  • OnSingleTapUp
  • OnTouch  (finger down on tab second time)
  • OnTouchEvent
  • OnDoubleTap
  • OnDoubleTapEvent  (down by OnDoubleTapListener)
  • OnDown
  • OnTouch  (finger lift off tab)
  • OnTouchEvent
  • OnDoubleTapEvent  (up by OnDoubleTapListener)

If your finger touch and slide across tab, it'll trigger event in turn:
  • OnTouch  (finger down on tab)
  • OnTouchEvent
  • OnDown
  • OnShowPress
  • OnTouch  (finger move on tab)
  • OnTouchEvent
  • OnScroll
  • OnTouch  (finger lift off tab)
  • OnTouchEvent
  • OnFling