Last weekend, I enjoyed lots of technical discussions on various new technologies including Android, Google APIs, HTML 5, Sencha Touch from some of the smartest people in the industry, together with free food and drinks and lots of swags from sponsors. Yes, this was Silicon valley code camp 2010.
It was a two day event, with 9 different tracks and over 190 sessions. The best part was it was totally FREE :) No, the best part was the learning, sharing, discussing, contemplating, questioning ... Did I mention free food? It was a huge success with close to 2000 attendees. It's a big deal because it's entirely run by volunteers.
Today I want to spend a moment to thank all those people who made this code camp a great experience for me. Special thanks to Peter Kellner for the endless hours he put in to make this possible.
I started my Day 1 with Introducing Google APIs Part-I (A-Z & Geo) session. It was quite informative given the vast variety of Google APIs. I found FusionTables very interesting and its integration with Google Maps APIs along with KMLLayer can result in some useful applications.
Then I head over to 'Android: Beyond Basics' session. Well, I was expecting to hear about some advanced topics, he covered the basic building blocks of Android except Activitiy which he had discussed in his first session, Android Basics. After lunch, I was in dilemma whether to attend Dancing with iOS or Sencha Touch. I am glad I chose Sencha Touch. David Kaneda described the Sencha Touch application framework that enables mobile web apps that look and feel native on iPhone and Android touch devices using primarily HTML5, CSS3 & JavaScript. It was like a roller coaster trip through Sencha framework. He touched so many things, it was hard to digest for a beginner like me. But I will mention few things here. David explained Syntactically Awesome Stylesheets (SASS) and the Compass framework and they together lead to more fun with style sheets. He also recommended, use of PhoneGap to prepare the Sencha Touch apps for both Android and iPhone.
Then I attended two more sessions from Google track - Google App Engine and Google Chrome / HTML 5. Both talks were equally engaging. I personally enjoyed Chrome session partly because I am currently working on Chrome OS and I could totally relate to what they were discussing. I was looking forward to day 2 for more talks on HTML 5.
I wanted to attend Do you Mapreduce? but it was clashing with 'Fun with HTML5, CSS3 and JavaScript'. This was really fun. Tab Alkins Jr (Google) coded a game live in front of audience. He covered only Canvas element so my thrust for HTML 5 was not yet satisfied and I went on to yet another HTML5 session - Mobile HTML 5 by Michael Galpin. I have read his articles on developerWorks so it was a nice opportunity to listen to his talk where he gave an detailed overview of HTML5 features. During lunch, there was a raffle with many exciting prizes including xbox which was fun (for those who won).
The session on Building Video Applications with YouTube API by Jarek Wilkiewicz was interesting because I never knew anything about it before. Some amazing statistics: YouTube gets
* 2B views/day
* 150m mobile views/day
* 24 hours of video uploaded/minute
The last session I attended was 'Mapping On The Phone' by Mano Marks from Google. It was an hands on session where he showed how to use GeoLocation feature of HTML5 together with Google Maps APIs.
It was a time for clean-up and I happily volunteered for this activity together with 10 other people. I was a nice feeling. I totally love my SVCC volunteer t-shirt :) My favorite moment was talking with Michael Galpin on video tag acceleration and application catch.
One of the side effects of attending this event is that I ended up opening my twitter account because almost everyone promised to tweet their ppt links!
Saturday, October 16, 2010
Sunday, October 3, 2010
OpenGL For Android - GLSurfaceView
One of the fascinating features of Android platform is its support for OpenGL. OpenGL is a cross-platform 2D and 3D rendering graphics library. An industry consortium, called Khronos Group maintains the OpenGL specification. http://www.khronos.org/opengl/
Let's get started with the code.
The main class we use is GLSurfaceView which extends from SurfaceView class. GLSurfaceView
OpenGL uses C-based flat APIs and hence we need to have a Java language binding to be able to use it with Android Application framework. Java ME has already defined this binding with JSR 231. (Java binding for OpenGL 1.5). What that means for you is -
import javax.microedition.khronos.opengles.GL10;
Let's get started with the code.
The main class we use is GLSurfaceView which extends from SurfaceView class. GLSurfaceView
- Provides a Surface onto which we can render OpenGL scenes
- Binds with customized Renderer which performs the actual drawing
- Manages EGL display
- Uses a dedicated GUI thread, decouples the main application thread for user interactions
We need to call one method on its object i.e setRenderer() which registers a user specified Renderer object that knows how to draw the desired shapes.
Activity's onCreate() will look like this - @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
GLSurfaceView view = new GLSurfaceView(this);
view.setRenderer(new SimpleRenderer());
setContentView(view);
}
The next thing we need is SimpleRenderer which will be responsible for actual OpenGL rendering. It implements GLSurfaceView.Renderer interface and defines its three methods.public abstract void onSurfaceCreated (GL10 gl, EGLConfig config)
This method is called at the very beginning e.g when a Surface is created or recreated ( when phone awakes after sleep), it's a good place for all initialization code.
A typical initialization sequence -
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
// Set the background color to black (RGBA).
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
// enable smooth shading
gl.glShadeModel(GL10.GL_SMOOTH);
// set up depth buffer and enable depth testing
gl.glClearDepthf(1.0f);
gl.glEnable(GL10.GL_DEPTH_TEST);
gl.glDepthFunc(GL10.GL_LEQUAL);
// use nice perspective calculations.
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
}
This method is called when the Surface size changes. The size (width, height) affects the aspect ratio so this function should contain the code that depends upon aspect ratio such as GLU.gluPerspective() . A sample code -
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f,
100.0f);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
}public abstract void onDrawFrame (GL10 gl)
This method is called when the current frame is being drawn on the Surface and thus actual drawing code goes here. e.g
@Override
public void onDrawFrame(GL10 gl) {
// Clears the color and depth buffer. -- clears the framebuffer
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslatef(0, 0, -5);
// Draw our square.
/* square.draw() */
}
This code will create a blank frame with black color. We will see the actual drawing code in the part 2. So stay tuned!
Tuesday, September 14, 2010
Add dictionary support to Notepad++
I love Notepad++. It's light-weight, support many languages, has word completion feature and also includes a Spell Checker. So for all practical purposes, it's a functional editor. Having a dictionary support in your editor is always the best thing and it's very simple when it comes to Notepad++.
Bingo! Now if you open Spell Checker, it will show you the list of misspelled words in the current document and possible suggestions.
It already has a plugin for Spell Checker which you can find under Plugins->Spell Checker ..
All it requires is GNU Aspell and a dictionary installed on your machine.
GNU Aspell is a Free and Open Source spell checker. It can either be used as a library or as an independent spell checker. Main features include
- possible suggestions for misspelled words
- supports UTF-8 document encoding
- supports multiple dictionaries.
Enable Spell checker in four easy steps -
1. Download and install Aspell for Windows from http://aspell.net/win32
2. Now install a dictionary which you can download from the same website.
3. Notepad++ requires a relative path for aspell-15.dll. Open Plugins->Spell Checker.. A dialog box will open where you can edit the relative path. I have both Notepad++ and Aspell installed in "C:\Programs Files" so I entered the path as "../Aspell/bin"
4. Restart Notepad++
Bingo! Now if you open Spell Checker, it will show you the list of misspelled words in the current document and possible suggestions.
Friday, September 3, 2010
Add git branch to bash prompt
If you use git, you will find this small trick very useful.
gitStatus() { git diff --quiet 2> /dev/null || echo ' *' ; }
To make your bash prompt super spiffy (and equally useful), add this to ~/.bashrc:
#Adding git branch to command promptgitStatus() { git diff --quiet 2> /dev/null || echo ' *' ; }
gitBranch() { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ > \1$(gitStatus)/" ; }
Then, somewhere in your $PS1, put \$(gitBranch). Here's an example; try it:
export PS1="[\u@\h$ \w\$(gitBranch)]\$ "
When you're in a git directory, you'll notice the branch name on the prompt. If the branch has been modified, an asterisk will appear next to the name. Here is an example :
My command prompt looks like this -
cdump@cdump-linux : /workspace/android/platform > cros-wm *$
indicating I am on cros-wm branch and there are modified files.
Git-goodness!
Credit Serban Giuroiu
Credit Serban Giuroiu
Tuesday, April 20, 2010
Android Application Launch Part 2
There are three distinct phases of process launch :

The Activity starts its managed lifecycle with onCreate() method call. The activity comes to foreground with onRestart() call and starts interacting with the user with onStart() call.
- Process Creation
- Binding Application
- Launching Activity / Starting Service / Invoking intent receiver ...
Process Creation -
ActivityManagerService creates a new process by invoking startProcessLocked() method which sends arguments to Zygote process over the socket connection. Zygote forks itself and calls ZygoteInit.main() which then instantiates ActivityThread object and finally returns pid of newly created process.
ActivityThread then starts the message loop by calling Looper.prepareLoop() and Looper.loop() subsequently.
Application Binding -
The next step is to attach the process to the specific application. This is done by calling bindApplication on the thread object. This method sends BIND_APPLICATION message to the message queue. This message is retrieved by the handler object which then invokes handleMessage() method to trigger the message specific action - handleBindApplication(). This method invokes makeApplication() method which loads app specific classes into memory.
This call sequence is depicted in following figure.
After the previous step, the system contains the process responsible for the application with application classes loaded in process's private memory. The call sequence to launch an activity is common between a newly created process and an existing process. The actual process of launching starts in realStartActivity() method which calls sheduleLaunchActivity() on the application thread object. This method sends LAUNCH_ACTIVITY message to the message queue. The message is handled by handleLaunchActivity() method as shown below.
Assuming that user clicks on Video Browser application. the call sequence to launch the activity is as shown in the figure.
The Activity starts its managed lifecycle with onCreate() method call. The activity comes to foreground with onRestart() call and starts interacting with the user with onStart() call.
Subscribe to:
Posts (Atom)