When I was a Boy Scout, we played a game when new Scouts joined the troop. We lined up chairs in a pattern, creating an obstacle course through which the new Scouts, blindfolded, were supposed to maneuver. The Scoutmaster gave them a few moments to study the pattern before our adventure began. But as soon as the victims were blindfolded, the rest of us quietly removed the chairs. I think life is like this game. Perhaps we spend our lives avoiding obstacles we have created for ourselves and in reality exist only in our minds. We're afraid to apply for that job, take violin lessons, learn a foreign language, call an old friend, write our Congressman - whatever it is that we would really like to do but don't because of personal obstacles. Don't avoid any chairs until you run smack into one. And if you do, at least you'll have a place to sit down. ~Pierce Vincent Eckhart
Friday, December 3, 2010
Tuesday, November 30, 2010
Programming Vs Blood alcohol concentration
http://xkcd.com/323/
I have always observed I code better when drunk but was not aware i am walking on a thin ice when icode while drinking or drink while coding or watever.
I have always observed I code better when drunk but was not aware i am walking on a thin ice when i
Wednesday, November 3, 2010
Android Project structure
PROJECT STRUCTURE:
When new Android Application created. It use specific directory tree structure showing in eclipse SDK platform .There are Eight key items show in project tree structure as follows
1. AndroidManifest.Xml2. bulid.xml
3. bin/
4. libs
5. src/
6. res/
7. assests
8. gen
AndroidManifest.xml :
When creating Android
application
must have an AndroidManifest.xml file in its root directory. It is an XML file describing the application being built and it contains activity, services, uses permission etc.When creating a new project automatically generated file in project it contains only single main activity of project.
- It describes the components of the application‚ the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities .These declarations let the Android system know what the components are and under what conditions they can be launched.
- IN AndroidManifest.xml  uses-permission elements, to indicate what permissions your application will need in order to function properly,
android.permission.CALL_EMERGENCY_NUMBERS
android.permission.READ_CONTACT
android.permission.SET_WALLPAPER.
- permission elements, to declare permissions that activities or services might require other applications hold in order to use your application’s data or logic ‚
- instrumentation elements, to indicate code that should be invoked on key system events, such as starting up activities, for the purposes of logging or monitoring
- uses-library elements, to hook in optional Android components, such as mapping services
- its declares the minimum level of the Android API that used in applications as well as it declare verion name and version code just like
android:versionCode=“1″
android:minSdkVersion=“3″
android:versionName=“1.0″
Build.Xml:
It is an ANT script for compiling the application and installing on the device.
BIN /:
When you compile your project (via ant or the IDE), the results go into the bin/ directory under your project root.
bin/classes/ holds the compiled Java classes
Bin/classes.dex holds the executable created from those compiled Java classes
bin/nameapp.ap_ holds your application’s resources, packaged as a ZIP file
bin/namedebug.apk or bin/nameapp-unsigned.apk is the actual Android application (where nameap is the name of your application)
The .apk file is a ZIP archive containing the .dex file, the compiled edition of your resources, any un-compiled resources (such as what you put in and the AndroidManifest.xml file. )
SRC/:
It contains all source code file (.java file) of android application. E.g hello_world.java
RES/:
Resources are to store all external contents that used in android applications.
These are external elements that you want to include and reference within your application, like images, audio, video, text strings, layouts, themes, etc.It contains all resources that are used in android application
Root directory:
- res/drawable : its contain images ,pictures (png, jpeg etc) e.g. .icon.png
- res/layout : contains XML(User Interface) that UI layout used in Project or view window of an application.(E.g. main.xml)
- res/Values : it declare Arrays, colors, dimensions, strings, and styles.(E.g. strings.xml)
- res/raw : it contains non-complied file (e.g. Audio file .mp3, video file .mpg)
“1.0″ encoding=“utf-8″?>
ASSETS:
Assets it also store an external content refer in android applications. Just like images, audio, video, text strings .It same as resources but different in assets directory will maintain its raw file format and, in order to read it, you must use the AssetManager to read the file as a stream of bytes. So keeping files and data in resources (res/) makes them easily accessible.
libs/:It’s holds any third-party Java JARs your application Requires.
GEN:
In Eclipse create an application that time auto generated R.java file in gen directory. The R.java file is an index (id) into all the resources defined in the file. This class files use in source code file or it gives for reference or location user interface object that uses in sources code.
Imp Note: Don’t change any code or id (assign value).
Sunday, October 31, 2010
Compile Hello World with Android source code
To run a helloworld application with the AOSP and see it in emulator
Once the android source is set up in your system and building fine.
1.You can copy paste the HelloWorld folder created in android-sdk into packages/app.
2. Copy
3. Add your package in the list in /build/target/product/core.mk
Compile the source code now and build the root directory. Once done you can find your package .apk file in out/target/product/generic/system/app/
build the make file then generates
To run the file in the emulator
To create a new system image file for the emulator (system.img userdata.img)
$ make install clean
$ make
Once the android source is set up in your system and building fine.
1.You can copy paste the HelloWorld folder created in android-sdk into packages/app.
2. Copy
Android.mk
from any other package and just have to change the LOCAL_PACKAGE_NAME
and make that one match the folder name in packages/apps.3. Add your package in the list in /build/target/product/core.mk
Compile the source code now and build the root directory. Once done you can find your package .apk file in out/target/product/generic/system/app/
build the make file then generates
To run the file in the emulator
path to android sdk/tools/emulator -avd my_avd -kernel common/arch/arm/boot/zImage -system out/target/product/generic/system.img -sdcard sdcard.img &
To create a new system image file for the emulator (system.img userdata.img)
$ make install clean
$ make
Saturday, October 2, 2010
Setting up Android source code
Changes to the file
1. To build on a 32-bit machine
To get rid of this error "Only 64-bit build environments are supported beyond > froyo/2.2"
/build/core/make.mk
- ifneq (64,$(findstring 64,$(build_arch)))
+ ifneq (i686,$(findstring i686,$(build_arch)))
Just be sure that instead of *64* you use your machine architecture (you can get it
running # uname -m) because mine is *i686*
2. To build with a java version of 1.5 instead of java 1.6
1. To build on a 32-bit machine
To get rid of this error "Only 64-bit build environments are supported beyond > froyo/2.2"
/build/core/make.mk
- ifneq (64,$(findstring 64,$(build_arch)))
+ ifneq (i686,$(findstring i686,$(build_arch)))
Just be sure that instead of *64* you use your machine architecture (you can get it
running # uname -m) because mine is *i686*
2. To build with a java version of 1.5 instead of java 1.6
Ubuntu inside Windows can't be more easy :)
Yesterday I tried installing Ubuntu inside Windows, it was so easy that I was tempted to write down steps for any future reference:
Required stuff:
1. 512 MB of RAM
2. Ubuntu - Download the ubuntu image of whichever version you want
File size: ~700Mb File format: .iso
If you have fast internet access it might just take a couple of mins
http://www.ubuntu.com/desktop/get-ubuntu/download
Else if your internet gets interrupted every now and then you might consider downloading
it through bit torrent
3. VirtualBox
Depending on your system version/configuration virtualBox can be downloaded from here
http://www.virtualbox.org/wiki/Downloads
Once the above downloads are ready follow the article for step by step installation
http://www.psychocats.net/ubuntu/virtualbox
Just the follow up of the above post to run virtualBox in fullscreen mode:
1. Install Ubuntu on VB.
2. After install and restart, go to the 'Devices' menu for VirtualBox.
3. Select 'Install Guest Additions'.
4. Open Terminal in Ubuntu.
Type:
cd /media/cdrom0 (this puts you to the cdrom directory where you just mounted guest additions)
Press enter then type:
dir (this shows you what's inside this directory.)
Press enter then type:
sudo sh ./VBoxLinuxAdditions-x86.run (this is what you would type if you have an x86 machine, typical. If you have an AMD use that one, and so forth.)
If this steps doesnt work for you try locating the file in following structure and run it VBOXADDITIONS_W.X.Y_Z/VBoxLinuxAdditions-x86.run
5. Wait for update to complete.
6. Once complete, shut down Ubuntu.
7. Restart VirtualBox
8. Boot up Ubuntu.
9. Once booted, press cmd+F for fullscreen or cmd+L for seamless.
There u go!
Required stuff:
1. 512 MB of RAM
2. Ubuntu - Download the ubuntu image of whichever version you want
File size: ~700Mb File format: .iso
If you have fast internet access it might just take a couple of mins
http://www.ubuntu.com/desktop/get-ubuntu/download
Else if your internet gets interrupted every now and then you might consider downloading
it through bit torrent
3. VirtualBox
Depending on your system version/configuration virtualBox can be downloaded from here
http://www.virtualbox.org/wiki/Downloads
Once the above downloads are ready follow the article for step by step installation
http://www.psychocats.net/ubuntu/virtualbox
Just the follow up of the above post to run virtualBox in fullscreen mode:
1. Install Ubuntu on VB.
2. After install and restart, go to the 'Devices' menu for VirtualBox.
3. Select 'Install Guest Additions'.
4. Open Terminal in Ubuntu.
Type:
cd /media/cdrom0 (this puts you to the cdrom directory where you just mounted guest additions)
Press enter then type:
dir (this shows you what's inside this directory.)
Press enter then type:
sudo sh ./VBoxLinuxAdditions-x86.run (this is what you would type if you have an x86 machine, typical. If you have an AMD use that one, and so forth.)
If this steps doesnt work for you try locating the file in following structure and run it VBOXADDITIONS_W.X.Y_Z/VBoxLinuxAdditions-x86.run
5. Wait for update to complete.
6. Once complete, shut down Ubuntu.
7. Restart VirtualBox
8. Boot up Ubuntu.
9. Once booted, press cmd+F for fullscreen or cmd+L for seamless.
There u go!
Subscribe to:
Posts (Atom)