Tuesday, December 10, 2013

"Command Not Handled Exception" after removing "XPageDebugToolbar_v3.0.1" custom control from XPages

It would have happened to me again. I mean the long trial and error and the wage wait process to find errors in XPages. For some reason, my XPage would not open up if I remove the XPageDebugToolbar_v3.0.1 custom control from my XPage. And again it worked if I added it back again.

I was like 0.o why would this happen. Has the Debug toolbar author found a way to mess up XPages if they dont need them anymore :P. 

Fortunately I remember that one of my dynamic view controls used a managed bean in which I had declared an object reference to the debug tool bar

private static final DebugToolbar dBar = DebugToolbar.get();

to the answer was to put "//" before the line of code and make it

//private static final DebugToolbar dBar = DebugToolbar.get();

Yeah. Comment-ing the code fixed the issue. Wierd. Guess it would have been better it does not error out and surprice like this. 

Tuesday, December 3, 2013

Getting current column name from dynamic view control in managed bean

I followed the standard example provided in the documents as well as visuals by NotesIn9.com

Hence I was trying to obtain my view name from one of the values in the "svals" variable. For some reason all my attempts kept failing and I even got worked up. I was tired and XPageDebugToolbar came to my rescue after a couple of days of headache.

"svals" seemed to hold references of all stuffs present in the page and that was a sheer nonsense in terms of what I was expecting

I got it through the following code fragment

for (Map.Entry entry: svals.entrySet()) {
dBar.info("Key = " + entry.getKey().toString() + ", Value = " + entry.getValue().toString());

So I tried using the ColumnDef object to determine the column name and that worked -

 if (colDef.getName().equals("C1")) {

Hurray I got my work complete now :). Hope this helps some one else as well :)

Debugging managed beans in xpages

I copied all design elements from the XPageDebugToolbar v3.0.1 to my database and followed the procedures to debug my code. Some irritating stuff kept throwing "Command Not Handled" exception.

The error page was set to the error page mentioned by the XPageDebugToolbar v3.0.1 as per the documentation and hence I changed it back to default settings. Now I was able to see some clear meaningless errors. rolf.
It displayed something like the dbar.warn or dbar.error pointed to undefined values and hence no such methods existed.

So I made an attempt to check the "eu/linqed/debugtoolbar/DebugToolbar" file. That is where I found a clear error which upon fixing fixed the issue. The class (java design element) did not open up and instead it spoke of some refresh error and asked me to hit F9. How wonderful.

Now I have a managed bean with following lines of codes in different parts of the class which enabled me debug and fix the issue.

private static final DebugToolbar dBar = DebugToolbar.get();

dBar.info(colDef.getName()+"==C1 is " + (colDef.getName().equals("C1")));

for (Map.Entry entry: svals.entrySet()) {
dBar.info("Key = " + entry.getKey().toString() + ", Value = " + entry.getValue().toString());

My code is now fixed and I am one happy me now. :)

Dont forget to download and use the XPageDebugToolbar. It is really a great work and made my life easier with XPages.

I used to use a custom built logger tool which I built a couple of years ago. I used the same to create log documents and dump all my debugging statements. This helped me watch my code all these years.Now that I had to use Dynamic View Control from Extension Library, I had to use managed beans to manipulate so me column values and hurray my xLog failed. It simply did not create any log documents. Some posts kept telling me to recycle objects after they are used. It did not help either.

Hope this helps some one. :)

Thursday, November 28, 2013

Roles in XPages - Part ||

I have tried obtaining user roles using different methods before. I think the following way is pretty simple to obtian an array or user roles and a comma separated string of user roles

var userRolesArray=database.getACL().getRoles().toArray()

var userRolesString="";

for (itr=0;itr
{ userRolesString+=userRolesArray[itr]+",";


My previous post on this topic can be navigated to by clicking on the following link

Monday, November 25, 2013

Could not open the editor: An unexpected exception was thrown - xpages

I was working with editable area controls and custom controls and for the first time, I used them together to find a time saver. Life(may be God) has its own way of playing with you. Rather I would call it insanely teasing you.

When I opened my XPage in the designer, I encountered the following error message

I felt like I was doomed. All my hard work for the day has went in vain as I did not take any backups :(

Eventually I started preparing my curse list starting with *hi**p Ri**d. No offense, just kidding. I closed down my Lotus Notes and opened it back again and the error vanished phew.... That was a silly damn thing to do. Saved me lot of hits against the wall with my head.

Also I found a post in the stackoverflow forum which gave me more ideas about why and how to handle this issue :)

Friday, November 22, 2013

A nice text font for websites

This post speaks nothing about any other technical stuffs. It is supposed to help me/ remind me with a the fact that the following combination of font-families and font sizes makes the page appear decent and good

font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;

A link like the following - XPages Extension Library - seems to be very neat too :)

I like the fonts used in the site Naveegator and also you can take a sneak peak at one of my post where I have some what ruined the UI

The styles for these links are pretty complex

color: #0077cc; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px; text-decoration: none;

Installing and running XPages Extension Library in your local machine

Shamelessly copy pasted from Naveegator

I had been hearing a lot about XPages Extension Library and finally got to try it out in XPages code-a-thon held at Mumbai. So I decided to try it on my local machine along with little help from experts on StackOverflow. Its a simple two-step procedure - install extension library and run extension library.

Install XPages Extension Library

First of all get the latest release of extension library from OpenNTF. Unzip the file and find "updateSiteOpenNTF-designer.zip". Unzip it and you will get two folders of "features" & "plugins" and a file "site.xml". In Lotus Notes sidebar, go to My Widgets and select "Options > Configure a Widget from... > Features and Plugin on an Update Site". If you are unable to see My Widgets in your sidebar then click here.

Now enter the URL for the update site as: file:///C:\updateSiteOpenNTF-designer.zip>\site.xml. Click on load button and you will get all the features in the extension library. Select all of them and click on Next and follow the instructions.

After you are done installing restart the Notes client. Then you would be able to see the extension library components in your Controls tab in Domino Designer.

Running XPages using Extension Library components

If you try to preview any XPage which uses extension library components then you would get an error as Cannot find the library com.ibm.xsp.extlib.library, required by the application . This is because the above procedure only installs the extension library only in Domino Designer, not in the local preview engine.

For that go to /domino/workspace/applications/eclipse and copy-paste the files from features and plugins extracted from updateSiteOpenNTF-designer.zip into their respective locations. Give Notes client a restart and you are ready to run XPages Extension Library.

onClick event not working in XPage Link Control - A work around

I have had issues with XPage Link Controls in the past, especially with the onClick events of the links. I was under an impression that I had a work around to solve it. Unfortunately I rediscovered that I still have issues with the same and my work around from the past failed.

It was because, I had a link with my known work around inside a table cell whose onClick event was coded.
My previous solution was for 8.5 version and with all of the new nice features in 8.5.3 I thought its time for me to go for a more stabler solution. And ended up with a better work around lol, may not be a perfect solution

In respect to my analysis, following is a possible list of reasons that your onClick event of XPage Link Controls would fail in 8.5.3

1. The onClick event of your Link Control might fail if you had associated a url to your link. Refer to the following image

2. When both URL and onClick events are provided on the XPage Link Controls, Page gets redirected to the linked url before its onClick event gets executed properly. Its a wild guess. Please check for its authenticity your self

3. The onClick event might fail on the wonderful IE browser if a parent container like a div or a table cell which contains the Link Control has code on its onClick event or other events like onMouseover etc

In order to over come all still be able to use both "link" and onclick event, remove the url mapping to the link control and use call a button controls onclick event on the client side onclick event of the link. And code all you want in the button both client and server side. This seems to remove alot of problems and has worked for me. I know that I am complicating stuffs with my words here, so take a look at the following image. Probably you would understand stuffs better.

And dont even think about screaming something like "HEY, THATS CHEATING. ITS NOT A FAIR SOLUTION". As I said earlier, this is a possible work around that has worked for me. I dont mean this to be a final solution :P

Friday, November 8, 2013

"last" link in Xpage pager control not working

I recently had to work with pager controls in Xpages.  I used to work with the default “Sample 1″ style for “Pager style” and this time I had to go for other styles that displays the "last" link in the pager. For some reason it did not render and instead I had to see a few dots instead of the "last" link.
It was as if some thing like "to be continued...." . Damn IBM walas... that was very good way to mock me :P
Eventually got my heart in mouth lol as I was under a lot of pressure to get it to work. With some research I found a post somewhere in the ibm developer works were a like minded person (may be) was enjoying this funny joke by IBM. One of the replies to that post suggested a work around hack to calculate total view entries count, divide it by number of documents being displayed and associate it with view control display etc...
I short I wanted my pager to look something like the following :
|< >| 
But it was looking something like the following
|< ..
I tried inspecting the pager and to my astonishment, it was never there. It was really something like "to be continued..." , I mean it was never calculated by the XPage
After some poking around and some more google searches, I found “alwaysCalculateLast” in the All Properties tab for the pager control. I set it to true and it works like charm :)

Thursday, November 7, 2013

Get label of link in XPages

In order to get value from a component like Edit box control etc in an XPage I use


When it comes to a link it will give you the URL Value that the XPage link control has been mapped. In order to obtain the Label or the Name of the link (and not url) you got to use the getText() method.

Following is a brief illustration of what I am talking about

Following is the result obtained on the browser

Get class name of Components in XPage

Its very easy to obtain the class name of components in Xpages. The only issue is that, its difficult if you dont know how :P

Well for starters (like me) drag and drop a control on to an XPage. Give it a name say "MyControl"

Now add a label to the XPage where you performed the above mentioned difficult steps and use the following code to compute its label


In my case I tried it with a link object and got the following stuffs on my screen

If you feel curious about understanding (most likely about simply knowing) controls better you can refer to the control documentation. Following post speaks about its where abouts.


Thursday, October 31, 2013

JSON Issues in XPages - Unknown literal of class com.ibm.jscript.types.FBSUndefined

This post does not speak about any fixes for this error message, however, contains a tip that will help avoid the issue.

I encountered this error when I tried to apply toJson method on a json construct.

I had the following json construct. Let me say this as "x"

{"menuItems": [
"serialNumber": 1,
"Label": "Label_1",
"subMenuItems": [
"serialNumber": 1,
"Label": "Label_1",
"subMenuItems": [


When i attempted some thing like toJson(x), I got the FBSUndefined error. How ever, when I attempted, fromJson(x) I got sort of I got the following error

Error when parsing JSON string
Encountered " "object "" at line 1, column 2. Was expecting one of: "false" ... "null" ... "true" ...blah blah blah

When I just put my json construct on to a field's default value and tried to parse the field's value using the following code


getComponent("result").setValue(y.menuItems.length)//-> result was 2.0 (i guess)
it worked like charm. Voila

I understand that this must be sort of, a beginner level stuff for Json in XPages.
If you would like to be saddened further by coding a lot to obtain perfection, may be you can explore "com.ibm.commons.util.io.json" and use them in your SSJS :P

Issues working with XPage Tabbed Panel Controls - Aligning Tab Headers with Margin

This was something that I was thinking to do for a long time but never had to do it before. Thanks to my most demanding customer who literally takes a scale and measures micrometer differences on the screen, I am now finding time for working with this finer details on the screen.

The goal is to get the tab headers of a Tabbed Control in XPages to align itself with the margin. I know we always play around with options available in the control's property tab to do it. Atleast I always do it that way :P. I did play around with margins and found some frustrating issues that resulted in some sort of "so-close" answers all the time.

Thanks to chrome and firefox and their developer modes, I was able to do something that pleases me.

Jumping straight to the point, my XPage Tabbed Control looked some what like one in the following screen shot

Hmm looking at this part of screen alone make me realize why my customer was like "WHAT THE HELL!!! WHY IS THE PASSENGER DATA OUT OF LINE!!!". That was scary :P

At last (so at least now) I was able to modify that to look like the following

  Looks pretty nice tight. My customer is really something. Wonder about the eagle eyes my customer has got :)

The trick that helped me do this is very simple. Just add the following to your style sheet

ul.xspTabbedPanelTabs {
left: 0px;

and by the way if you are interested, its 10px by default. Thank you wasting some of your time reading my story and not scolding me :)

Monday, October 28, 2013

Working with Design Definition in Custom Controls - XPages

I see design definitions in Custom controls as the name states are for providing a design description.

I see this more like a beautification part to your design. Cos I think , simple multiline comments also would serve the same purpose. The top side is , I looks good when included on the XPages.

The down side is, I feel little irrated to work with the xml mark up I have to provide in the Design Definitions tab.

Coming to the point, the simplest syntax that I learn is, you got to provide xml markup inside the Design Definitions text area as you would do in a normal XPage. Take a look at the following screen shot on how/where to provide the markup value

If you do this, you custom control when included on an XPage, would look  something like the following on the designer

Looks pretty design to me :), at least better when compared to the native appearence

Working with Property Definition in Custom Controls - Xpages

I found a nice lesson about this in Xpages 101. Hola, my innernet connection was awesome, that I was not able to view the video through the vimeo player. With a bit of research, I was able to figure it out and thus this fine article :P

I dont remember using this or seeing this in 8.5 or 8.5.1. And now I see that this is very useful and can be used in a lot of ways. To me this feature really does make more sense to the existence or employment of custom controls in designs. As a matter of fact, I think I should start sticking with Custom controls and use Xpages only to resuse my custom control. Dont O.o me if you think other wise. May be I am just curious

Jumping right on to the topic, try the following and you may understand how it works.

1. As always, You must start with creating or using an existing custom control. Open it and go to the properties pane.

2. Now add a property to the custom control as illustrated in the following screen shot. In addition you can go to the validation and visible tabs and code your way as per your necessity

3. Now include this custom control in some XPage and click on the custom control. You will find a tab called as "Custom Properties" when you select the included custom control. You can infer what I see in my case. I see the property that I created and I am able to assign a value to it

4. The little diamond symbol beside the custom property value says I can do stuffs like link it with a scoped variable or some thing :). Think you get the idea

5. Now to see how to provide and retrieve the value for/from the custom property, create a computed field in your custom control and look for compositeData. You can find your property name and use it as per your requirement.

There you go. Hope this helps :)

Tuesday, October 1, 2013

Accidentally discovered Mirror Image of L (:P)

Do not expect any serious stuff from this article as expectations might lead to disappointments. Was casually working and happened to punch in a couple of keys by mistake and found a ridiculous character which I have never seen before in the Lotus script editor (Of course I had seen it in other platforms).

I cannot type in that symbol here as I did on the lotusscript editor, so as an alternative I will do the most brilliant thing of showing you a screen shot, rofl.

I guess its easy for you to see what I am speaking about in the image. I must say that I have found some thing different to decorate my multi line comments with :)

Also I tried an msgbox on that. Seems to work. Another discovery - mirror image of L, rofl

Now I can give more meaningful message boxes for my client ;P

Monday, September 30, 2013

Crash Lotus Notes - Oops I did it again

In an attempt to write a fairly complex workflow application, which I originally thought was a so simple I did this. I was dumb enough to have given way for the "out of touch since last two years" concept to ridicule me like this.

I knew that theoretically, I can write custom lotus script classes which can extend native lotus script classes and I can possibly extend/create events like querySave, queryClose etc using some thing like the following

On Event Querysave From customUidoc Call customQuerysave

So I went a head and tried it to discover that I crashed my client. I am great full that I dont posses the talent to corrupt database designs at will. Honestly.

Sometimes the thought scares the hell out of me. I just tried to do the above mentioned stuff. Just tried. And following happened. Note- I am not sure if this would happen always or not, but I think its worth mentioning this. I already had a custom class on the script library where I was trying to build my new custom class and extend NotesUIDocument.

I am on the way persuading about what really guided me to collapse my Lotus Client.  Hope I would find a solution to the same :@  !!!!

Saturday, September 21, 2013

Handling Variants - Becare full about the Type Name or Class Name of Variants refering to Array Objects

Variants now a days are proving more useful to me than before. I stick to the thought that I should not use variants unless its really necessary. One of the most effective advices that I received from developers against using variants is based on the fact that it takes 16bytes memory space for the object where is its less in case of objects for integer, string etc.

I often get the feel that with the current hardware capacities heightened to tera bytes, 16 bytes wont matter that much, if we recyle them properly.

I performed a small test today as my code kept failing and failing and there was not much for me to look for.

I first checked what type of values result in which type of variants. So I did the following in a test button

Eventually, I previewed the button on a client interface and did the MAGIC JOB of clicking it. And there comes my BELOVED BABY popups as to the left.

Now I understood that these are of types "INTEGER", "STRING" and "STRING()"

Is there any soul out there who agrees with me. If so, join the club and clean your eyes/specs and look at the god damn thing properly.

It is actually "STRING( )" and not "STRING()". This screwed me for over 30 minutes. Some time back due to a specific individual in my life, I became of fond of reading and understanding the "LAWS OF STUPIDITY". The fourth law stated that,

"Non-stupid people always underestimate the damaging power of stupid individuals. In particular non-stupid people constantly forget that at all times and places and under any circumstances to deal and/or associate with stupid people always turns out to be costly mistake."

Now my question is who is stupid - Me , the Variant or ***

Saturday, September 14, 2013

Obtain class name of objects in lotusscript

Several months ago, I explored how to create overloaded functions in Lotusscript. I had posted about the same as well. Recently I went through a thought which required me to find a way to get the class name of a lotusscript object in the run time. It really took me some time to eventually recollect that I knew the answer already until I went through my own posts again.

Thought I would make it simpler with a proper titled post dedicated for this issue of finding the class name of a lotusscript object on run time.

The lotusscript key word that does it is "TypeName". Though I had used this for doing the overloaded functions, It took me an hour to recollect it X(. Guess I had grown rusty in the last two years with less coding. Am happy now, that I get enough stuffs to challenge my skills again

In short, following is a little illustration about the way this keyword works. For a quick test, add the following code to a button and test it on Notesclient.

dim doc as NotesDocument
dim uiDoc as NotesUIDocument

msgbox TypeName(doc)
msgbox TypeName(uidoc)

Now when you click on the button, you will receive a couple of prompts saying

Thursday, September 12, 2013

Crash Lotus Notes - Oops I did it again

It has been quite a while since work was such fun. :) I had missed to log a lot of ways by which I ended up crashing lotus notes last year as they seemed obvious and straight forward. This time I think I discovered a new way to do it :P

It is by make a view feel miserable when a document is opened from it. Yep its the queryOpenDocument event of the view.

I just put the following code into it

Sub Queryopendocument(Source As Notesuiview, Continue As Variant)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim currDB As NotesDatabase
Dim selectedDoc As NotesDocument
Dim caret As String
Set currDB=session.CurrentDatabase
Set selectedDoc=currDB.GetDocumentByID(caret)
Call workspace.SetTargetFrame("*********")  '- dont get any ideas. Just put a valid frame name 

Call workspace.EditDocument(False,selectedDoc)
End Sub

This happens even if I comment "continue=False" 

I really dont know about how to fix it rolf :)

Tuesday, September 10, 2013

Custom sort using @Sort in lotus notes

I happened to cross through a scenario where I had to perform a custom sort in such a way that a list of words appear in a drop down in such a way that "Red" if present always appears first followed by "White" and "Blue" if they are present and the rest of the list must be alphabetically sorted.

I found a close way to do that but not the best solution though. It took me quite a while to understand the way the parameters "$A" and "$B" were used in the @Sort function.

I use a list named a s"myList" as an input parameter. The list elements present inside my list is as follows

Blue : Custom : XCustom : Red : DCustom : White

Take a look at the following code.

@Sort(myList; [CustomSort]; @Do(
@UpperCase($A)="WHITE" & @UpperCase($B)="RED";1;
@UpperCase($A)="WHITE" & @UpperCase($B)!="RED";-1;
@UpperCase($A)="BLUE" & (@UpperCase($B)="WHITE" | @UpperCase($B)="RED") ;1;
@UpperCase($A)="BLUE" & !(@UpperCase($B)="WHITE" | @UpperCase($B)="RED") ;-1;
) )

The out put that I have obtained is as follows

Red : White : Blue : Custom : DCustom : XCustom 

When I change the last line of code to @UpperCase($A)<@UpperCase($B) my out put becomes
Red : White : Blue : XCustom : DCustom : Custom 

It returns two types of values 1 and -1. The confusion was, It is supposed to return an integer equivalent for @true and @false which are to my understanding 1 and 0 respectively.

I dont know how was one able to think about the scenario of using -1 as a return type which was not documented in Designer help. It works great.

As per my understanding if you return
1 - it means $A will be put behind $B in the list after the comparison occurred
0 or -1 - it means $A will be put in front of $B in the list after the comparison occurred.

-2 ( and probably all other negative number) is treated like 0 as well O.o

Tuesday, September 3, 2013

Colors in Lotus Notes View Columns

I always wanted to document this, but often felt lazy about doing it. Thus this got delayed by almost 4 and half years. Can you believe that? I can. I know I am better at doing stuffs more worse than this.

This post is typically about how you give different colors to different columns in Notes Client. Actually there is no such thing. Hence as always we end up doing simple work arounds. Let me give you a visual sneak peak before you end up reading my entire post and feel bored

Thats looks color full doesn't it :). The trick behind these colored columns with custom backgrounds are using hidden columns with "Use value as colors" enabled with a column formula like

backgroundColor:textColor where each of these would assume a value between 000000 to ffffff or 0:0:0 to 255:255:255. Refer to following image for more details

If you take a closer look at the image, you will be able to see that I am referring to three small columns with no titles and the two important properties "Use value as color" and "Hide column" enabled.

Make a note of the way in which I had assigned the color values to the variables. They are not in quotes. I have assigned the numbers colon separated just as is. So these variables are typically arrays containing three color codes as its elements

Thursday, August 22, 2013

No communication ports found in notes ports dialog after installation issue

I had a tough time figuring out how to communication ports for Lotus Notes to use and connect to servers.

The issue was simple and the background was funny. I needed Lotus Notes to be installed and the guy who helped me out gave me a client but no designer/admin clients. Felt great and had a headache trying to help him understand what I want. And finally I did it again - "gave up" and figured out an other way to do it myself. It feels like I am experiencing the attitude face that Mr.Han wanted from Xaio Dre during his training.

Now I got the installation files and completed installing Lotus Notes and found that I was not able to connect to servers.

I went to File -> Preferences -> Notes Ports and "Awe :/ No Communication Ports found X("

I tried adding TCP to the list and trace my server it did not work.

So went through uninstallation and re installation horror and the issue still persisted.

This time I had ! over my head. When I tried to trace a different server I found that the port I added was missing.

So the Answer is "ADD A PORT NAMED TCP AND FOR GOD SAKE RESTART YOUR LOTUS NOTES" and it worked. This time the "Show status" button really shows info on my TCP port that I added

Feeling relieved at last - again - ;'|

Tuesday, August 6, 2013

Android Application Development 5 – Action Bars

I have an advanced device with me. So I am going to be selfish here. I want to know what I can do with my device and see what my device is capable of. So I am going to try out stuffs that work good with my device. So if you are working with a device that is lesser than Andriod 3 and if you find this not helping you, you could probably visit developer.android.com for exhaustive neat documentation.


Running down what I have understood so far in respect to the previous posts Android Hello World Part 1 to 4

1.      Define layout in activity_main.xml

2.      Define ids to elements (they are the view objects as per SDK) use android:id="@+id/yourid"

3.      + symbol comes behind the @ symbol for id declarations alone

4.      The above said declaration will help me access my element using R.id.yourid

5.      @symbol is required to refer any resources

6.      setContentView(R.layout.activity_main); -> will look for the layout defined in the activity_main.xml file in the layout folder and render it .

7.      Call the above mentioned line in the onCreate event of the activity to get the layout

8.      Use findViewById(R.id.yourid) to find your components. Its equivalent to document.getElementById in javascript.

9.      Use "Intent" objects to communicate between activities

10.  Use Intent.putExtra(key,value) to transfer values

11.  Use startActivity(Intent) in button clicks to start activites


Now its time for the action bars to come into the picture.


I intend to add a couple of actions to the action bar of my main activity page. In order to do that

create the following xml file  -  res/menu/main_activity_actions.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <!-- Search, should appear as action button -->

    <item android:id="@+id/action_search"



          android:showAsAction="ifRoom" />

    <!-- Settings, should always be in the overflow -->

    <item android:id="@+id/action_settings"


          android:showAsAction="never" />


For some reason, the following line kept erroring out.




So I added the following line of mark up to the strings.xml file

<string name="action_settings">Settings</string>


And added an image by the name ic_action_search to the project file as illustrated by the following screen shot


To add the action to the action bar, Modify the onCreateOptionsMenu in the MainActivity.java call to the following


    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.

       MenuInflater inflater = getMenuInflater();

        inflater.inflate(R.menu.main_activity_actions, menu);

        return true;



To respond to the action button clicks add the following function to the mainActivity.java class. Note the way in which the ids of the action items are being used


    public boolean onOptionsItemSelected(MenuItem item) {

        // Handle presses on the action bar items

        switch (item.getItemId()) {

            case R.id.action_search:

               // openSearch();

                return true;

            case R.id.action_settings:

               // openSettings();

                return true;


                return super.onOptionsItemSelected(item);





Now to ensure that we are able to navigate from the child activities to the parent activity, we need to add a up button in them.


Honestly, it got created automatically even before I realized the need for it. So may be the following code is required for some lol faulty advanced mobiles

Add this to the child activity class' onCreate function. In this case it is the DisplayMessageActivity.java class


Now I see an action button my action bar. Yeppieee



Monday, August 5, 2013

Android Hello World Part 3 - Installing the app in your Android

Now I have a simple hello world app that I was able to test in my Android device by running the app from the eclipse environment.

Ok. Now I want to run the app directly on my Android with the help of eclipse. What should I do. I searched through the sources in the innernet and came to know about the “.apk” files which means Android Application Package File.

I trust eclipse J I should be having this goddamn file somewhere in my eclipse workspace and I don’t have the patience to search for it. I used windows search to find the file only in my bin folder of my first android app. How stupid am I lol. I am way out of touch to have forgot such a simple idea.

Quickly I moved the file into my favorite folder in the Android device. Then I got the wonder full security message mocking me to hell
I paid 40K bucks for this stupid device and yet it calls me a stranger. How about that thought!!! It’s OK I can live with that. After all I have to live with women around me in my life. I feel like an elite soul who cannot be hurt with such simple insults rolfJ

Tap on the Settings button to navigate to the Application settings sub-menu. If you’re trying to get there without an application warning screen prompt, navigate there via Settings –> Applications. There you’ll see a screen that looks like so:
What we’re interested in is the Unknown source, check the box beside it. You’ll get a stern warning, click OK and double check that the box is checked properly.
At this point you can now click on that link or navigate to the APK file saved on your SD card and install the application. We recommend that you go back into the Application settingsonce you’re done installing your non-Market applications and uncheck the box—it’s only a few clicks to enable it again in the future when you need it
Now I see my cute app in my mobile screen J Hurray !!!

Android Hello World Part 4 - Uninstalling the app from your Android

Now to the most important part of the sequel. How the @#@^ do I uninstall this useless app from my device. I don’t want it to stay there forever and ruin my opportunity to make more terrible mistakes.

Getting rid of the app was not that difficult. Go to settings, get into application manager or my apps or apps or whatever is relevantly present in your mobile and uninstall it. Worst case scenario, you can even download new apps to do it J I don’t think it will ever come to this.

Go through the following link for some decent documentation

Thursday, August 1, 2013

Android Hello World Part 2

This is a continuation from the previous post.

To respond to the button's on-click event, open theactivity_main.xml layout file and add theandroid:onClick attribute to the <Button> element:

android:onClick="sendMessage" />

The android:onClick attribute’s value, "sendMessage", is the name of a method in your activity that the system calls when the user clicks the button.

Open the MainActivity class (located in the project's src/ directory) and add the corresponding method:

/** Called when the user clicks the Send button */
public void sendMessage(View view) {
// Do something in response to button

This requires that you import the View class:

import android.view.View;

Build an Intent

An Intent is an object that provides runtime binding between separate components (such as two activities). The Intent represents an app’s "intent to do something." You can use intents for a wide variety of tasks, but most often they’re used to start another activity.

Inside the sendMessage() method, create an Intent to start an activity called DisplayMessageActivity:

Intent intent = new Intent(this, DisplayMessageActivity.class);

An Intent can carry a collection of various data types as key-value pairs called extras. The putExtra()method takes the key name in the first parameter and the value in the second parameter.


An intent not only allows you to start another activity, but it can carry a bundle of data to the activity as well. Inside thesendMessage() method, use findViewById() to get theEditText element and add its text value to the intent:

Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
.putExtra(EXTRA_MESSAGE, message);

Note: You now need import statements forandroid.content.Intent and android.widget.EditText.

Start the Second Activity

To start an activity, call startActivity() and pass it your Intent. The system receives this call and starts an instance of the Activity specified by the Intent.

With this new code, the complete sendMessage() method that's invoked by the Send button now looks like this:

/** Called when the user clicks the Send button */
public void sendMessage(View view) {
    Intent intent = new Intent(this, DisplayMessageActivity.class);
    EditText editText = (EditText) findViewById(R.id.edit_message);
    String message = editText.getText().toString();
    intent.putExtra(EXTRA_MESSAGE, message);

To create a new activity using Eclipse:

1.    Click New  in the toolbar.

2.    In the window that appears, open theAndroid folder and select Android Activity. Click Next.

3.    Select BlankActivity and click Next.

4.    Fill in the activity details:

o    Project: MyFirstApp

o    Activity Name: DisplayMessageActivity

o    Layout Name: activity_display_message

o    Title: My Message

o    Hierarchial Parent: com.example.myfirstapp.MainActivity

o    Navigation Type: None

Click Finish.

If you're using a different IDE or the command line tools, create a new file namedDisplayMessageActivity.java in the project's src/ directory, next to the original MainActivity.java file.

Open the DisplayMessageActivity.java file. If you used Eclipse to create this activity:

·         The class already includes an implementation of the required onCreate() method.

·         There's also an implementation of the onCreateOptionsMenu() method, but you won't need it for this app so you can remove it.

·         There's also an implementation of onOptionsItemSelected() which handles the behavior for the action bar's Up behavior. Keep this one the way it is.

Because the ActionBar APIs are available only on HONEYCOMB (API level 11) and higher, you must add a condition around the getActionBar() method to check the current platform version. Additionally, you must add the @SuppressLint("NewApi") tag to the onCreate() method to avoid lint errors.

The DisplayMessageActivity class should now look like this:

public class DisplayMessageActivity extends Activity {

protected void onCreate(Bundle savedInstanceState) {

// Make sure we're running on Honeycomb or higher to use ActionBar APIs
// Show the Up button in the action bar.

public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
return true;
return super.onOptionsItemSelected(item);

Add the title string

If you used Eclipse, you can skip to the next section, because the template provides the title string for the new activity.

If you're using an IDE other than Eclipse, add the new activity's title to the strings.xml file:

    <string name="title_activity_display_message">My Message</string>

Add it to the manifest

All activities must be declared in your manifest file, AndroidManifest.xml, using an <activity> element.

When you use the Eclipse tools to create the activity, it creates a default entry. If you're using a different IDE, you need to add the manifest entry yourself. It should look like this:

<application ... >
        android:parentActivityName="com.example.myfirstapp.MainActivity" >
            android:value="com.example.myfirstapp.MainActivity" />

Receive the Intent

Every Activity is invoked by an Intent, regardless of how the user navigated there. You can get the Intentthat started your activity by calling getIntent() and retrieve the data contained within it.

In the DisplayMessageActivity class’s onCreate() method, get the intent and extract the message delivered by MainActivity:

Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

Display the Message

To show the message on the screen, create a TextView widget and set the text using setText(). Then add theTextView as the root view of the activity’s layout by passing it to setContentView().

The complete onCreate() method for DisplayMessageActivity now looks like this:

public void onCreate(Bundle savedInstanceState) {
    // Get the message from the intent
    Intent intent = getIntent();
    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
    // Create the text view
    TextView textView = new TextView(this);
    // Set the text view as the activity layout


The final set of code that you would have arrived could be the following






This enabled me to do the following J