Voice Recognition API in Android Apps Using RecognizerIntent

Category : Android, Google, Java, Open source, Software development

Voice interface is not a common application user interface, we do not usually interact with application using voice. But when it comes to mobile it makes more sense.
We are used to talk to a phone all day – why not talk to our phone apps?
Not all voice interaction should look like this video:

Here is how you use Android Voice Recognition API:

  1. Call the RecognizerIntent  - your application call the Voice recognition Intent that records the voice.
  2. Intent processes the voice recording – sends it to the voice Recognition Service and returns
  3. A list of string is passed to an implemented callback method in you application
  4. You process the string and continue the interaction with the user

Here is a simple call to the intent:

     * Fire an intent to start the speech recognition activity.
    private void startVoiceRecognitionActivity() {
        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speech recognition demo");
        startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);

And here is the callback:

     * Handle the results from the recognition activity.
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
            // Fill the list view with the strings the recognizer thought it could have heard
            ArrayList matches = data.getStringArrayListExtra(


        super.onActivityResult(requestCode, resultCode, data);

Here is a full code sample – I played with it today and will very little effort created a Pizza ordering application for my next demo session.

Will Oracle kill Java and MySQL?


Category : Java, Open source, Tips

Oracle is going to buy Sun and control Java and MYSQL.1
In an interesting post in ZDNET ,Mr Shuttleworth, the founder of Ubuntu is claimed to state that:

“.. he doesn’t seem too worried that the proprietary software company will kill Sun’s open source Java, OpenSolaris and MySQL jewels, in spite of Oracle’s hold on the database market.”

I am not sure I completely share his optimism. I am not so much worried about Java, there is no competition there. But think of it -If you were Oracle’s CEO, You just got the chance to kill the number one competitor product- Wouldn’t you want to kill MySQL?

Even if you do not do it immediately, would you want to invest in two competitive technologies? It just doesn’t make any sense business-wise.

Additionally, I don’t buy the “so what? Open source products can be forked” story. I do not think Java and MySQL would have been so successful without a solid company backing them up. I really hope that Oracle will provide this solid support and investment in the future of Java and MySQL.

My hope it that Oracle cares about its public image in the open source community and that this will drive Oracle to keep MySQL and Java open and alive.

No Dolphins were hurt in the making of this post.

Language syntax’s, performance, PHP, Ruby, Java and who’s better? Ahhhh!


Category : Java, PHP

Language syntax’s, performance, PHP, Ruby, Java and who’s better? Ahhhh! -
I was reading on The Server Side and came across this post:
which is part of this overall discussion:
Tim Bray: Java is less scalable than PHP
The overall topic is interesting, especially since the premise is further clarified by the person who did the presentation, who goes on to point out that, what he’s attributed to having said, is not what he actually said! Making a good point of the idea that context, presentation, etc. all affect the meaning of any statement whether it’s with humans or computers.
Having said, that, my post starts off dinging him on a better syntax for the Lisp and Smalltalk he shows or mentions and then goes into a rant on our current state of affairs.

So here it is:

The Lisp and Smalltalk can be just as simple.
Here is an example:

(loop for n from 1 to 10 do
(format t "i is ~A~%" n))
i is 1
i is 2

< removed for brevity >
i is 9
i is 10

Smalltalk is just as easy:

1 to: 10 do: [:each | Transcript show: "i is ", each]

The post also had this quote:
These last 30+ years have taught us that most programmers feel reasonably >comfortable with languages that follow the syntax pioneered by C and >Basic.

I’m not so sure I’d agree with that. There are many programmers that did quite well with Lisp, COBOL, ADA, Smalltalk, RPG, Perl, shell, Fortran, etc. The things and ideas your exposed too, along with the multitude of ways that you learn to think, affect more about which languages you are comfortable with than syntax. I started with Basic, Forth and Assembler, but once I learned Lisp and Smalltalk, I found that they allowed me to think in much more flexible and effective ways and to solve problems of greater magnitude. I continue to find that true to this day.
While I can get things done in Java or C++, the work and bastardization of my ideas that must take place due to the constraints of the language structures and features, make me do much more work than I’d like. And this is even with all the frameworks etc., I can not easily encode many ideas without ending up in pattern-itis and code bloat. And on top of that quite a few of those frameworks have there own views of the world and structures/patterns I must conform too.
I think it is lost on today’s programmers and enterprise developers that the Smalltalk and Lisp systems of the late 70’s and going through the early 90’s did windowing, networking, email, threading, document systems, etc. all on systems that used about 1/5 th the code as compared to C/Unix versions of similiar tools. We also get many of the techniques for optimization of the JVM and OO systems from work on or inspired by those early systems. (Hotspot came from Strongtalk and Self work) To this day those systems can perform just as well or better than the JVM.
But like I said, I think a lot of this is lost on most programmers today. They tend to worry about IDE refactoring across many hundreds of files (what happened to loose compling??), type inferencing (they don’t know that HotSpot doesn’t use most of the typing in the code, but chooses the best code path from cached run-time generated native code), they’re interface and delegation happy (while not learning from the bloat that caused in the MS COM world) and a lot refuse to open their minds to learn from many other languages, tools and approaches because it’s not the religion of today!
I’ve see a lot of this cycle and rhetoric before though, so history is just repeating itself. The C++ prgrammers poo-pooed the Smalltalkers and at first the Java guys as well, till they themselves became Java users. As Java pulled in VM technology from Lisp and Smalltalk and got faster, and started to run on as many platforms as Smalltalk (most people don’t know that in the early 90’s that Smalltalk ran on approximately 40 platforms in a true write-once run-anywhere mode not the dream Java had for the first few years), more and more programmers jumped on the bandwagon.
Now the Java world is being shacken up, but this time, they are sounding like the C++er’s of old, but it’s funny, because some of the Java old guard are leaving the religion and seeing the bigger world again. Not only that, they’ve seen that you can get more and more dynamic and still perform and have safe tested systems. They’ve also seen that all those patterns and work arounds they’ve been applying to try to get back that dynamic behavior they’ve so wanted aren’t needed as much or at all in some of these new languages and systems.
We still here a common theme though! Most still want type safety. Lisp proves you can have both worlds and people are going that way. I think people want a language that lets you add type safety as needed. It’s the future and even the guys as SUN know that other languages are coming and they are maneuvering to try to be ready for the next big thing.
Am I saying Java dead or less useful? Not at all! What I am saying is that as we wish for more and challenge Java more, we are wanting more of what we already have great examples of. We must continue to open our minds to not only what is new, but to what is old but new to us! We need to see the power of that old stuff, and remember to be humble, b/c the reality is that a lot of what we think is new has already been done almost 30 years ago by some very smart people, many of whom still go to work today like you and me, but who are very patient, knowing that great things have a way of reappearing.
Keep your eyes open and remember just as Java has opened peoples eyes and incorporated many lessons from what was done before it, it can continue to do so, but it may well be passed by, by some new language and toolset. SUN is trying to make sure they are a part of that revolution or evolution whichever one it is.

Java brought together in one package a lot of the things that people needed and wanted at the time, such as familiar syntax, platform portability, basic abilities to do netowrking and web work, then added everything that people learned from the old CICS systems and CORBA enterprise knowledge. That’s a big chunk of computing and they assembling it all together in Java and it is a great feat! Great for all of us!
Now some people are looking back at other things that were learned and achieved and hoping to add the best of those other ideas as well. Quite a lot of these “new” things were again found in those old research systems. (Not suprising really). I for one can’t wait. They’re awesome systems.
In the interest of disclosure, I have two Lisp Machines, several Smalltalk systems and am a devout believer in the dynamic, exploratory programming style that those systems encourage. I have worked on and solved many large mission critical and corporate applicaitons with said tools as well doing the same for similiar systems in Java and C++.
Off the high horse now… and I hope you’ve found this thought provoking!
[on java]

Ajax persistent Data Objects – AjaxDo 1.1 released!

Category : AJAX, Java, New Release, PHP, Software development

Release 1.1 adds a fully functional JAVA server-side implementation to the pre-existing PHP server-side implementation. Now, Ajaxdo, AJAX

persistent Data Objects, enables applications can work in a JSP/JDBC environment and port easily from PHP to JAVA and vise-versa.

Code, examples and documentation can be found here.

Spring-Dashboard 1.0 released under the apache license!

Category : Java, New Release, Open source

Release 1.0 contains a framework for gathering statistic runtime information on spring web application, a configurable dashboard view with a default AJAX implementation and an example application that demonstrates the Spring-Dashboard basic abilities.

Why is Java-enabled hosting so expensive?


Category : Java, Opinion

Why is Java-enabled hosting so expensive?

Hosting a website is a cheap matter these days. One could get a fairly good shared hosting package for around 1.5-6$ per month. These hosting packages offer a wide variety of features including support for PHP, PERL on LINUX or ASP (or ASP.NET) on Windows and MySQL DB. The problem is that prices soar when you want JSP/Servlet support.

I think Java should be as affordable as PHP and .NET or else it will loss a lot of private developers to the competitors. Expensive Java hosting is a problem when you want to deploy a privately-held/budget-aware website.

I like Java and wanted my open-source website to be written in Java. At the end I had to settle for PHP (which is cool too).

Why should ASP/PHP enabled hosting cost 1.5-10$ per month and Java enabled hosting cost 12-30$ per month?

Amir Shevat
[Amir blog and articles]

Still waiting for true .NET – JAVA interoperability

Category : Interoperability, Java, Opinion

Still waiting for true interoperability

One of the big things presented in JavaOne was .NET-Java interoperability. The notion of language interoperability can be understood and implemented in several different ways.

Sun and Microsoft introduced interoperability by means of web-services (WS). It seems that short of a cure for cancer, web-services is the answer to everything. While in some conditions WS is a good way for applications (written in different language or the same) to interact, this seems like a cumbersome way for simple (POJO) situations especially when the two applications are on the same machine.

Our open-source project, MantaRay, also tries to achieve language interoperability. We provide our JMS offering in Java and .NET, thus you can send a message in C# and receive it in java and vice versa. We keep the protocol layer unified to provide our language interoperability, while this might be simpler or even faster than WS it basically suffers from the same shortcomings.

Another solution presented in the JavaOne pavilion was of shared memory between .NET and Java. This is an interesting approach for interoperability within the same machine. But it lacks an event driven mechanism and method invocation, you need to write your own code that checks if the shared variable has changed. So this is, in effect, a very thin offering.

And there is JNI for Java-C++ interoperability. In the alumni “fire side chat” the guys from SUN admitted, when asked why JNI invocation takes so long, that JNI is sometimes slow and that Java itself used “dirty optimizations” in order to achieve better C++ invocation speed.

There was a company that implemented a “source time/compile time” interoperability approach, you write you code in .NET and access Java libraries as you see fit. At compile time your code is converted to Java. They showed a very simple demo and I am not sure what the limitations of this solution are.

I have a dream, in my dream you write the code in any language you like and mash-up different languages. I would like to write a multi tier application, writing every tier in a different language, and not worry about interoperability.

Technology should enable things. It should be simple and efficient. Interoperability is an issue because of licensing, lack of standards, lack of good will and business competition. As developers, and consumers of technology, we must strive to be able to use the right tool for the right task, we should push for open standards and seamless interoperability. We must make sure the technology providers (Microsoft and Sun) know that is important for their business to provide this interoperability for us.

Amir Shevat
[Amir blog and articles]

Tip: how to write an XML document with JSP for AJAX applications


Category : AJAX, Java, Tips

AJAX applications usually connect to a server side application and request data in the form of XML. When the server side is written in JSP (Java Server Pages), for example a spring-framework web application with JSP views, writing the XML response is sometimes problematic.

The problem:

When using JSP to format the data in to XML and send it to the AJAX application, the XML is not recognized as XML (empty DOM object) and the AJAX application does not function properly.

The solution:

Add this to the beginning of the JSP

response.setHeader(“Cache-Control”, “no-cache”);


In addition, make sure there are no spaces between this addition and the root tag of the XML in the JSP, these spaces might create the same problem.

An example of this AJAX-JSP communication can be found in the Spring-dashboard code under the examples folder in this release (files: monitorData.jsp and monitor.jsp)

Another issue you might face with AJAX is client side caching. You can read more about this and how to solve this issue in this article – Solving the browser caching problem of AJAX applications

Removing the Ant Configuration Selection in eclipse


Category : Java, Tips

When I updated to eclipse 3.2 I found a new irritating feature:

The problem:
The first time when selecting the Run As-> Ant build… on any of the ant tasks (targets) you have in your build.xml file, you get a window called “modify attributes and launch.”

After that any time you try to run an ant task (with or without the build…) you get an annoying “Ant Configuration Selection” window that makes the ant running process a click longer.

The solution:
From the top menu select run->External Tools-> External Tools… which will bring you to “create, manage, and run configurations” window, there delete all the pre-defined tasks under ant build (on the left bar of the window) and click “close”…
I found this workaround here: http://dev.eclipse.org/newslists/news.eclipse.platform/msg20976.html

I hope eclipse will provide a different mechanism that will work around this problem in their next release.

JComet 0.1 released under the apache license!

Category : Java, New Release, Open source

Release 0.1 contains a dynamic properties file that can monitor its source configuration file and reload whenever it is modified. It also provides the ability to register listeners that are notified when properties change.