Calling JavaScript Function from Android and Handling Result

In this tutorial I am going to describe JavaScriptInterface  for Calling Android Function from JavaScript i.e., JavaScript Binding to Android.

Setting up WebView
First add JavaScriptInterface to webView as follows. Here "MyAndroid" will be used later to call functions in JavaScriptInterface later.

google adsense payment in nepal - western union quick cash

Google recommend  Electronic Fund Transfer (EFT)   as a faster and more reliable form of payment. But, EFT are currently only available to a limited number of countries. Which doesn't include Nepal. So we have the only good option : Western Union Quick Cash.

Receiving payments by Western Union Quick Cash:

Western Union Quick Cash is a payment method that allows you to receive your AdSense payments in cash using the worldwide Western Union money transfer service. Payments will be available for pick up at your local Western Union Agent the day after they are sent according to our normal payment schedule.
Your Western Union Quick Cash payment will be made in US dollars. Conversion rates will be calculated according to the rate used by the Western Union Agent on the day you pick up your payment.

Steps :

1) Setup Google Adsense payment to Western Union Quick Cash:


  1. Sign in to your account at www.google.com/adsense.
  2. Visit the Home tab and click Account settings in the left hand panel.
  3. Click 'edit payment method' under the 'Payment settings' header.
  4. Select the Western Union Quick Cash radio button.
  5. Click Continue.
  6. Click Save changes to save your payment type.

2) Picking up WU payment

In order to pick up your payment by Western Union Quick Cash, please complete the following steps:
  1. Find a Western Union Agent located in the country where your payments are sent.
  2. Call the Western Union Agent to confirm that they offer the Quick Cash service.
  3. Bring the following information with you:

    - a valid government-issued photo ID (Passport, Driver's license, National ID etc)
    - sender's information: To determine which sender's information you should bring to your WU branch, please check the 'details' link on the payment line of your Payments page.
    • Google Inc. 1600 Amphitheatre Parkway, Mountain View, California 94043, USA. Phone Number:  650-253-4000     
    - amount of your payment, which you can find on your Payment History page
    - your unique MTCN (Money Transfer Control Number) which you can find by clicking on the 'details' link next to the Payment Issued line on your Payment History page
Hurrahs ------- Lets have a party ... 

java find path of current executing jar

Best solution : 
String path = Test.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String decodedPath = URLDecoder.decode(path, "UTF-8");
You can use your own class name instead of 'Test'

Android JavaScriptInterface tutorial and example for calling JavaScript function from Android

In this tutorial I am going to describe JavaScriptInterface  for calling JavaScript function from Android i.e., JavaScript Binding to Android.

I have written a blog post about : Calling JavaScript Function from Android and Handling Result

Setting up WebView
First add JavaScriptInterface to webView as follows. Here "MyAndroid" will be used later to call functions in JavaScriptInterface later.

Android WebView WebChromeClient example tutorial

WebChromeClient is used to handle a JavaScript events in Android App which are produced by WebView. The examples of such events are : 
  • onCloseWindow
  • onProgressChanged
  • onJsAlert
  • onJsConfirm
  • onJsPrompt
  • onJsTimeout

Android WebView Complete Example Tutorial

The WebView class allows you to display web pages as a part of your activity layout. WebView becomes helpful  when your application frequently displays content from online resources.It simplifies task of performing a network request, parsing the data and rendering it in other Android layout. We can directly make HTTP request to an URL and load the returned HTML into WebView.


In this tutorial I am going to demonstrate usage  of WebView.

XSLT : Using reusable XSL to generate HTML Form dynamically

In this article , am going to describe how to generate html form dynamically using reusable xsl file.


Problem Statement :

Suppose I have large number of xml files :  There is one condition that : there won't be any more nested tags . But the name of property tag will be different for each xmldata file.
First xml:

Xsl transform in Java working example (xml to html)

In order to display XML documents, it is necessary to have a mechanism to describe how the document should be displayed. One of these mechanisms is Cascading Style Sheets (CSS), but XSL (eXtensibleStylesheet Language) is the preferred style sheet language of XML.
XSL can be used to define how an XML file should be displayed by transforming the XML file into a format such as HTML, PDF, etc..

Java - Single instance of application - working source code example

Having a single instance of an application is crucial in most of the software. In this article, I am giving an example on how to implement single instance of  an Application.
How it works :
  1. New instance of application tries to connect to a specific ServerSocket (localhost, port#) to detect running applications. And a running application must have a ServerThread to detect possible run of new instance of the same application
  2. The main Logic in steps
    • Find existing server socket running on localhost
    • If found(another instance was already running) --> exit current instance of application
    • else --
      •  start a new Server thread to detect run of future applications
      •  and start the application
Complete source code :

Some useful Regular Expressions for Find/Replace in Eclipse IDE

Regular expressions is powerful tool mostly used in search, edit and manipulate text. A regular expression define a search pattern for strings. The abbreviation for regular expression is "regex".Regular expressions are used in several programming languages. But, unfortunately each language / program supports regex slightly different.

In this blog, I am going to explain the use of Regular Expression(regex) in Eclipse IDE. There are eleven examples in total.