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

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 偵測網路是否連線

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

Not useful Google API for Android application

July 5, 2009 at 12:47 pm | Posted in android | Leave a comment
Tags:

Google Gears
Gears is an open source project that enables more powerful web applications, by adding new features to web browsers.

Google Coupon Feeds
Google coupon feeds enable businesses to provide coupon listings that will be included in Google search results.

Create a activity with no background

June 23, 2009 at 2:20 pm | Posted in android | Leave a comment
Tags: ,

Insert android:theme=”@android:style/Theme.Translucent.NoTitleBar” in application tag.

Delete large number of file by ‘find and rm’

March 26, 2009 at 1:04 am | Posted in android | Leave a comment
Tags: ,

find ./ -iname ‘test-file-*’ | xargs rm -rf

rm 有最大刪除檔案的限制,大概是 2 萬個,若超過會出現錯誤訊息。
The maximum file limitation of deletion one time about 20 thousand.

引用:使用 find 搭配 rm 刪除大量檔案

Next Page »

Create a free website or blog at WordPress.com.
Entries and comments feeds.