Skip to main content

Posts

Showing posts from September, 2011

Threads and Handlers

Newbies in Android face difficulty with communicating between different threads. It is better to create a new background thread instead of delaying the UI thread when there is lengthy task. Let us say you want to read an html file. If you read this file in UI thread, the program appears to be unresponsive. Hence it is better to read the file in a background thread. But when this reading is completed, how do you show the html in a webview in this example? The background threads can not access the ui widgets. Hence there is a need to communicate between ui thread and background thread. This can be done with Handlers. Handlers are used to send and process messages. A handler created in  a thread, can process all the messages sent by this thread. You should create a handler class for processing messages private class MyHandler extends Handler{ @Override public void handleMessage(Message msg) {     if(msg.getData().getString("message").equals("y

Kannada/ Hindi/Marathi keyboard for Android

Many of you might be wondering how to type kannada in your android phone.  I have developed and published an app in android market which is kannda Input Method Editor.  Here is the link .  You install the apk and then you enable the keyboard. During typing, make sure you select kannada input method. In fact my app supports Devanagari font also. So those of you who want to type in Hindi/marathi can use the app. Please leave your comments and help me in improving it.

Orientation change in android

Many times you want to have a different layout for landscape view and another one for portrait view. The simplest way to achieve this is 1> create folder    /res/layout-land 2> in this folder store your layout xml file for landscape view 3> The xml file name must be same for both portrait and landscape orientations That's it. Now if the user rotates his screen, automatically the landscape layout will be used And when user changes orientation, the activity restarts. If you do not want that to happen Add this line to manifest file <activity android:configChanges="orientation|keyboardHidden" -- > Now the activity will not restart if the orientation is changed.