Moved to Blogger

January 24, 2011 at 2:34 am | Posted in Uncategorized | Leave a comment

This blog will not be updated and move to Blogger
Sorry for the inconvenience.

git

January 12, 2011 at 11:45 am | Posted in android, ubuntu | Leave a comment
Tags:

git diff
find the different between local and server.

git diff .
find the different between . and server.

git reset –hard
all the changes are lost.

git reset –hard HEAD~2
reset to previous 2 commit

git reset –hard
reset to commit-id

git pull
sync code

git branch -f
change branch

git checkout
check out

count from file output

January 12, 2011 at 11:39 am | Posted in ubuntu | Comments Off on count from file output
Tags: ,

cat file | cut -f 1 | awk ‘{tot=tot+$1} END {print tot}’

Check if SD card storage is available

August 9, 2010 at 6:43 am | Posted in android | Leave a comment
Tags:

public static boolean hasStorage(boolean requireWriteAccess) {
String state = Environment.getExternalStorageState();

if (Environment.MEDIA_MOUNTED.equals(state)) {
return true;
} else if (!requireWriteAccess
&& Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
return true;
}
return false;
}

Reference:
Android: Check if SD card storage is available

check if any network connected

July 27, 2010 at 11:07 am | Posted in android | Leave a comment
Tags:

private boolean checkIfNetworkConnected() {
  boolean result = false;
  ConnectivityManager connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
  NetworkInfo info=connManager.getActiveNetworkInfo();
  if (info == null || !info.isConnected()) {
    result = false;
  } else {
    if (!info.isAvailable()) {
      result =false;
    } else {
      result = true;
    }
  }

  return result;
}

Reference:
Android 偵測網路是否連線

7z in Ubuntu

June 28, 2010 at 2:42 am | Posted in ubuntu | Leave a comment
Tags:

sudo apt-get install p7zip-full

//x: Extract with full paths
7z x 7zfile

grep

April 26, 2010 at 8:08 am | Posted in android | Leave a comment
Tags:

-i, –ignore-case
Ignore case distinctions in both the PATTERN and the input files. (-i is specified by POSIX.)

-R, -r, –recursive
Read all files under each directory, recursively; this is equivalent to the -d recurse option.

-v, –invert-match
Invert the sense of matching, to select non-matching lines. (-v is specified by POSIX.)

-w, –word-regexp
Select only those lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a non-word constituent character. Similarly, it must be either at the end of the line or followed by a non-word constituent character. Word-constituent characters are letters, digits, and the underscore.

make sdk fail about DroidDoc

September 30, 2009 at 10:34 am | Posted in android | Leave a comment
Tags: ,


$ sudo apt-get install sun-java5-jdk
$ cd /etc/alternatives
$ sudo rm javadoc.1.gz
$ sudo ln -s /usr/lib/jvm/java-1.5.0-sun/man/man1/javadoc.1.gz javadoc.1.gz
$ sudo rm javadoc
$ sudo ln -s /usr/lib/jvm/java-1.5.0-sun/bin/javadoc javadoc

Reference:
編譯Android cupcake SDK

how to remove ^M in vi

September 22, 2009 at 1:24 am | Posted in android | Leave a comment
Tags:

:1,$s/^M//g

^M: Ctrl+V, and press Enter

Basic Concept of Android Application Components

July 7, 2009 at 2:30 am | Posted in android | Leave a comment

Activity
An application may or may not have a User Interface. If it has a user interface, it will have one or more Activity.

Service
If an application is to have a long life cycle it should be put into a Service. For example a background data synchronization utility running continuously should be implemented as a Service.

BroadcastReceiver
Like Services, BroadcastReceivers do not have a User Interface. Of even more importance, the code running in the onReceive method of a BroadcastReceiver should make no assumptions about persistence or long-running operations. If the BroadcastReceiver requires more than a trivial amount of code execution, it is recommended that the code initiate a request to a Service to complete the requested functionality.

Content Provider
If an application manages data and needs to expose that data to other applications running in the Android environment, a ContentProvider should be implemented.

Reference:
Unlocking Android – A Developer’s Guide

Next Page »

Blog at WordPress.com.
Entries and comments feeds.