Tuesday, October 30, 2012

Android Web View - Progress Dialog, Full Screen

Android provides WebView to load the Web pages inside the application itself, we can customize this webview according to our needs.

Traditionally we will use handlers to handle the events but in android we can use the pre-defined methods to handle the events,

In this post i have explained how to load progress dialog while page is being loaded and hoe to keep the web view in the full screen mode .

1.Full Screen:
                      To use the web view in the full screen just use the simple code given below.


The only condition using this is , you should use this code before setContentView as given in the project file attached with this blog post.

2.Using Progress Dialog:
                         As i mention earlier you can use progress dialog until your page gets loads. 

Once you complete the inflation process use the following code

               web.setWebViewClient(new WebViewClient() {

               public void onPageStarted(WebView view, String url, Bitmap favicon) {
                dialog =, null,
                        "Please Wait...Page is Loading...");
                super.onPageStarted(view, url, favicon);

                public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);

The first method will be triggered once the page is start loading, as shown below

The Second method will be triggered once the page is completely loaded,once it is triggered the dialog will get disappeared, as shown below

You will get this dialog every time  you navigate inside the web view, as shown b 

 For more detail you can use this eclipse project here

Get the code in  GitHub

Happy hacking...

Sunday, October 21, 2012

Getting Started with WordPress (Installisation and Configuration)

Designing a web site made easy with the CMS ( Content Management System). One of the very famous CMS is WordPress.
Here i have explained the installation steps for WordPress.

2.Web Server
3.Data Base Server

Where can i get all these requirements?  

All the above requirements are available in the Internet.

                         WordPress can be downloaded from the official site - here 
You will get the zipped file just extract the file. we will get started once we get other two requirements.

 2.Web Server
                          Web Server is the one which is use to run the web pages and serves to the web clients.
The very famous web server is Apache. We will see the installation and configuration of web server below.

3.Data Base Server
                            WordPress needs Database, so we need a separate server.
                             I use My sql as a database server.

 Is Internet connection is mandatory ?
  1. Yes, you need Internet to download the required stuffs.
  2. And you may not need Internet connection for designing the web site if you follow OFF LINE Procedure written in this blog.
  3. Also you need Internet to host your web site after designing.
Does Initializations of two server will take much time?

            Actually we are not going to setup servers for a very big application like ,

This made easy with XAMPP
X- Cross Platform of
A- Apache

So we got two servers in one package. Its absolutely Free of cost.You can download and install xampp for both Windows and Linux here.

Note: Kindly disable all the firewalls, anti virus(Windows), previously installed web servers, Database servers.
 Because Apache will use port 8080 and MYSQL will use port 3306.

Once you installed the XAMPP. Open its directory and open the XAMPP control panel by opening the file "Xampp-control".

Here you can see "Apache", "Mysql"  click on start on both the servers, you will find those are running as shown below

Once both the servers are started you can proceed the WordPress Installation.Now click on the Admin button of the Apche . It will open the xampp splash screen in the web browser.

Select the Language.

It will open the Xampp Home Page (http://localhost/xampp/index.php)

In this URL localhost is the directory that i have installed xampp. In the above figure you can see the current directory as "D:\program files\xampp". 8080 is the default port used by the Apache server. 

We can now install the WordPress, Extract the WordPress folder from the zipped file that you downloaded.

Copy the folder and paste inside the htdocs folder
xampp installed directory -> apache -> htdocs.
In my case
D:\program files\xampp\apache\htdocs
Paste the folder inside this folder because apache web server's configuration folder is htdocs.

I have pasted the folder named "wordpress" inside "htdocs"

Now open the browser and open the URL

Once you open it you will get a error page that you did not configured wp-config.php as shown below

So Click the "Create Configuration File" button and the new page open as shown below

 Now Lets Go!, The New Page Opens a form to setup the WordPress configuration as shown below

Before Getting Started, you need database for the WordPress so open the Xampp- control Panel and click on the My sql admin. or open http://localhost/phpmyadmin as shown below

Enter the new database name in the textbox and click on create.

I have entered as wordpress.

Close this page, In the WordPress installation Fill the
DB Name As "wordpress"
UserName as "root"             Root User of MySql
Password as ""                      Clear that field because MySql will not have any password by default
Database Host as "localhost"    Since we are running server in loclhost

Click Submit it will install necessary tables in the database and now the new page will open asking site details as shown below

Enter the site title
Enter the Preferred User name             
Note:This will be needed for logging in to the site to add, edit, delete content.
Fill the password
Note: Be careful it is also needed to log into the site
Enter e mail id
Click Submit.

It will open the another page click on Login.

The Login Page will appear as shown below

Enter the user name and password that you have given in the previous form.
Once you are authentic to the system the page redirect to the Dashboard of your site as shown below

This is the place where you can edit your site.

To Visit your site
i have given the folder name as wordpress so
To Open the admin dashboard just add /wp-admin to the URL

You Have successfully installed WordPress.
Happy Hacking

Thursday, October 18, 2012

Handling Orientation changes - Android

There is a difficulty for the UI/UX designers to design the User Interface for the android application. The major problem i see is the orientation change, Usually smart phones have two orientations they are portrait, Landscape. If you design the UI in the portrait orientation it will be in the vertical manner (i.e) the height is larger than the width . When you see in the Landscape orientation it is in the horizontal manner (i.e) the width is larger than the height.

To over come this problem i have used two different layouts in the same name.



Design for portrait orientation in this file

This file will be loaded for the portrait orientation.

create a new folder named layout-land under the res folder. Now create the new xml file in the same name, in this example it is activity-main.xml


Design for landscape orientation in this file

This file will be loaded for the Landscape orientation.

These layouts will be automatically loaded by the android system when you change the orientation. The data you typed in the fields will be available even after changing the orientation because it it will not destroy the activity.

Use Ctrl+F12 to switch the orientation of the emulator in Linux (Ubuntu).

Happy Hacking...

Wednesday, October 17, 2012

HTTP Session in JSP Servlet - Example

Hey Every one , As we know HTTP is a state less protocol so it is necessary to carry out session in the web application. If you were wondering  how your browser remember your session though the http is stateless, it is very simple.

I have attached the war file with source code . Import the war file to your eclipse.

Also I have attached the file "DB.sql" u can use it as the query log for setting up Database.

I have used the my sql as my back end database.



War File


Inserted of this SQL file you can also use the following sql queries

INSERT INTO LOGIN VALUES("arun","immanuel");

Happy Hacking...

Android Emulator KeyBord Commands

Hey droid developers make use of the shortcut keys of the android emulator .

I have tested with the ICS Emulator shown below

Emulated Device Key Keyboard Key
Menu (left softkey) F2 or Page-up button
Star (right softkey) Shift-F2 or Page Down
Back ESC
Call/dial button F3
Hangup/end call button F4
Search F5
Power button F7
Audio volume up button KEYPAD_PLUS, Ctrl-F5
Audio volume down button KEYPAD_MINUS, Ctrl-F6
Camera button Ctrl-KEYPAD_5, Ctrl-F3
Switch to previous layout orientation (for example, portrait, landscape) KEYPAD_7, Ctrl-F11
Switch to next layout orientation (for example, portrait, landscape) KEYPAD_9, Ctrl-F12
Toggle cell networking on/off F8
Toggle code profiling F9 (only with -trace startup option)
Toggle fullscreen mode Alt-Enter
Toggle trackball mode F6
Enter trackball mode temporarily (while key is pressed) Delete
DPad left/up/right/down KEYPAD_4/8/6/2
DPad center click KEYPAD_5
Onion alpha increase/decrease KEYPAD_MULTIPLY(*) / KEYPAD_DIVIDE(/)

Format External Devices - Linux

It is very common formatting a External drive. People think that linux is not supported in this feature. Actually Ubuntu does have this feature in the GUI but it is possible in the Command line.

Get the root access in the command line

user6@samgha-desktop6:~$ sudo su
[sudo] password for user6:

Unmount the device

umount /dev/sd                                                  -  Make sure the device you have selected the proper device.

Now enter the following command

root@samgha-desktop6:/home/user6# mkdosfs -n "ANDROID" -I /dev/sdb
mkdosfs 3.0.12 (29 Oct 2011)

Here "ANDROID" is my external device.

Happy Hacking...

Tuesday, October 16, 2012

Sclae Web Page according to the Device Size - Android 4.0 WebView

Web pages can be opened from the application using the web view. The actual problem come when you open the web pages in different screen. It is not a good idea to create the page or a application for every devices. So what to do ...?

It is possible to scale the web pages in web view it self now lets see how .

Create the web view layout in res/layout.home.xml


Inflate this in a java file

WebView webview;
webview = (WebView) findViewById(;

This will open the web page that is not properly fit into the screen so the solution is very simple just add three more lines.


Happy Hacking..

Tuesday, October 2, 2012

Tabs at the Bottom of the Activity

Tab Layout in android always displays the tabs at the top, but this occupies lots of space at the top of the application.

This could be overcome by very few steps

  1. In your vertical LinearLayout, put the FrameLayout above the TabWidget
  2. Set layout_height to wrap_content on both FrameLayout and TabWidget
  3. Set FrameLayout's android:layout_weight="1"
  4. Set TabWidget's android:layout_weight="0" (0 is default, but for emphasis, readability, etc)
  5. Set TabWidget's android:layout_marginBottom="-4dp" (to remove the bottom divider)
Full Code

Twitter Bird Gadget