2011年4月20日 星期三

Adding an SD Card to an existing AVD

You can easily do that manually:
1- find the path where your avd is stored
$ SDK/tools/android list avd
....
Path: /home/user/.android/avd/myAVD.avd
...
2- create an "sdcard.img" in that directory -- that name is the
default and the emulator will pick it up automatically:
$ SDK/tools/mksdcard 16M /home/user/.android/avd/myAVD.avd/sdcard.img
Run mksdcard without arguments to see the options. Size is something
like 128K or 128M.
Note that "list avd" will not display it after (it only displays
what's in the myAVD.avd/config.ini file... you can add a line like
"sdcard.size=16M" if you want "list avd" to show it.

How to use external JARs in an Android project

Your Project -> right click -> Properties -> Java Build Path -> Libraries -> Add Jar -> yourjar.jar

How To Generating R File

Project => Clean
Clean proects selected below
choice your project.

2011年4月2日 星期六

What's the “dot” for when registering an Activity

<activityandroid:name=".NewActivity"></activity>

http://developer.android.com/guide/topics/manifest/activity-element.html#nm

android:name
The name of the class that implements the activity, a subclass of Activity. The attribute value should be a fully qualified class name (such as, "com.example.project.ExtracurricularActivity"). However, as a shorthand, if the first character of the name is a period (for example, ".ExtracurricularActivity"), it is appended to the package name specified in the .



As you have noticed the point is not necessary but it basically means: the activity class lives in the same package of the app. So, if your app package is: com.my.package then:

.YourActivity means that your class is inside com.my.package.
YourActivity means that your class is inside com.my.package (same as above).
.activities.YourActivity means that your class is inside com.my.package.activitites.
You can even do something like: com.my.package.activities.YourActivity which is useful when you want to have different versions of your app and use Ant to change the references to the package automatically.