Preapproval Process using PayPal MPL in Android

1 Comment


The objective of the document is to explain the steps involved in doing auto renewal payment in PayPal using its Mobile Payment library for android mobile.

Steps to get confirmed PreApproval Key

  1. The first step towards integrating PayPal with android application is that we need a PayPal sandbox account for testing. So create new sandbox account if you don’t have one from following URL
  2. Sign in with the user id and password.
  3. Create Test accounts for both buyer and seller. You will get the API credential while creating seller account, those API credential will be used for getting preapproval key and payments.
  4. From your Local server send the preapproval request to paypal using the following parameters. You should use your account details and API credentials here.
    1. requestUrl:
    2. requestMethod: POST
    3. requestBody: requestEnvelope.errorLanguage=en_US&cancelUrl= buyer mail id
  5. If the above process and parameters are correct you will get a Preapproval key from server as response.
  6. Response:{“responseEnvelope”:{“timestamp”:”2011-09-21T02:54:44.020-07:00″,”ack”:”Success”,”correlationId”:”606efc1b8abb0″,”build”:”2142261″},”preapprovalKey”:”PA-81Y46219NL419022F”}
  7. This Preapproval Key say PA-81Y46219NL419022F has to authorize by the application. Pass the Preapproval key and merchant name to PayPal MPL from your android application. Here we used “SimpleDemo” android application given by the PayPal MPL library for understanding purpose.
  8. The Mobile User should login and agree the PayPal preapproval payment. After the user agreement the preapproval key get authorized and return back to the application.

Steps to make Payment

From your Local server by using the authorized preapproval key you can make a payment using the following parameters.

  1. requestUrl:
  2. requestMethod: POST
  3. requestBody: requestEnvelope.errorLanguage=en_US&actionType=PAY&preapprovalKey= Authorized preapproval key&receiverList.receiver(0).amount=30.00&receiverList.receiver(0).email=your seller mail id¤cyCode=USD&feesPayer=EACHRECEIVER&memo=Simple payment example.&cancelUrl=http://your_cancel_url&returnUrl=http://your_return_url&ipnNotificationUrl=http://your_ipn_notification_url

If the above parameters are correct the amount mentioned in the “receiver(0).amount=” column will get transferred to the seller account and you will get a Pay Key as response from the PayPal server. You can login in to both seller and buyer account to ensure the above process.


Caveats with Titanium Framework


Titanium Framework


Appcelerator Titanium is a platform for developing mobile and desktop applications using web technologies. Titanium Mobile Framework allows web developers to apply existing skills to create native applications for iPhone and Android. Its target audience is Web developers who does not want to learn objective-c or java but wanted to contribute to iPhone and Android development.


1. Titanium supports nearly all of the iPhone, iPad and Android UI controls

2. You can use most of the native facilities of the device like camera, accelerometer to state few.

3. You avoid learning new language and reuse the existing web skill set.

4. it lets you develop the business logic of the Application only once.

5. Most UI components can be reused across platforms.


In my opinion, a web developer can not find a disadvantage with the Titanium Framework.

Titanium is for whom?

Titanium is meant for people who never wanted to learn the native iphone and Android programming. If you know to develop applications using objective C and you wanted to develop applications for iPhone then don’t even think of Titanium, the same case applies to Android too. Only if you are lazy to learn a language, you can opt for Titanium.

My Experience:

I put here some of my observations I have had on Titanium Framework during my development.

  1. Developing for iPhone or Android alone is never a big deal. Because you need not bother about your application’s behavior in the other platform.
  2. Your application would be slower than if it has been developed in the native way and this would be visible very much with Android. In Android at most cases, for each of your page navigation you will have to finally add an activity indicator, if you have lot of controls in your view.
  3. Some of the features in Android which was shown to be working in developer reference were not working. Even after being filed as bugs, they were not updated in developer’s reference that it works only in iPhone. For example, “focus” events of the window is handled only in iPhone and never in Android.
  4. If you wanted to develop application for both iPhone and Android, then you would be spending more time for arrangement of controls in the views or custom cell in Table view.
  5. For a folk who is new to javascript or does not know the nuances of javascript, the development sometimes can be a nightmare because of the errors you get due to misplace comma, semicolon. But once you start coding carefully, this can be solved.
  6. Next biggest problem you would face with Titanium is with the Testing of the App in iPhone. It has taken nearly 4 minutes for the application to get loaded in to the iPhone. This was not the case with Android.
  7. The size of the Application is a big concern here. An iPhone application we developed using Titanium was 5.2 MB in release mode. If we could have done this in Native mode would not exceed a size of 1 MB.

If you wanted to develop an application that is completely data centric, you can go for Titanium but with all the pains I have mentioned. If you don’t know objective C or java, Titanium is a great gift for you. Otherwise you may regret choosing Titanium at later point in time.

After I completed my development of an Application for iPhone and Android in Titanium, I felt that if I could have directly used objective C and java to develop these applications. And this could have given me the following advantages:

  1. My application could have been faster than it is now.
  2. I need not wait for Titanium to enable a new feature that arrives with iOS or Android.

All of my experience that I have stated here are specific to my development of the Android and iPhone in Mac OS X.

I have used only Titanium Mobile. I have not used Titanium Desktop to develop any applications.


PayPal Integration in iPhone and Android

Leave a comment

I was curious to know if PayPal would support Credit card Payment using their Mobile library for iPhone and Android. But finally I got to know the fact from a PayPal guy that we can not just do a checkout only with credit card details. We always need a paypal account to checkout.

The good thing with PayPal is that they have officially launched the Mobile Library for iPhone and Android, otherwise developers would have a high time, getting the trust of the users and crossing the big Apple’s Approval process gate. It could have better if their library directly supports the Credit card only checkout.

Let us hope that, they bring that feature sooner.

Imageview Problem in Android – Titanium

Leave a comment

Yesterday I was working to scaledown the dimension of an image for my Application in iPhone and Android using Titanium. Without any effort I could achieve it in iPhone, but when I tried the same in Android I did not get the result I was expecting. The image was always taking up its original space without getting scaled down.

Finally I got to the solution. In iPhone implementation of Titanium, by default the image is set to be scalable and for Android the it is not scalable.

Setting canScale property to true and enableZoomControls to false did the trick for me.
By Default, enableZoomControls is true in Android. That is why we have set it to false.

Here is the code. Grab it.

var imageView = Ti.UI.createImageView({
    width: 40,
    height: 40,
    image: '/logo.png'

Solution to update Android SDK independently without using Eclipse


Recently when I tried to update Android SDK to latest version i.e 2.2, API 8, revision 2 from eclipse, I got a warning on the lines below

Failed to rename directory

-= Warning ! =-

A folder failed to be renamed or moved. On Windows this typically means that a program is using that folder (for example Windows Explorer.) Please close all running programs that may be locking the directory.

Many people have reported this error and though there are various solutions (like renaming the tools folder under <Android_Installation_Path>\android-sdk-windows\tools and update from that folder etc), there is no single solution that fixed this bug.

Ther bug is also reported in the

The core issue is indeed somebody else locked the tools folder. So I tried the following solution and it worked like charm

  • Close Eclipse and close all instances of windows explorer in which the <Android_Installation_Path>\android-sdk-windows\tools folder was opened
  • Now run the AVD Manager independently as follows
  • Open a command prompt.
  • Go to the directory where android sdk is installed at, and then its tools subdirectory.
  • Run Android.bat.
  • At this point, update just as you would if you were running the AVD Manager from within Eclipse (make sure the proxy settings are mentioned if you are behind the proxy).

You should be able to update the Android SDK now.

Enabling Android Market in emulator

Leave a comment

Following are the easy steps to enable the google’s best Android market to make available in Android emulator1.5 and 1.6.

1) Download the System Image zip file from the HTC website

2) Extract the system.img file from the zip folder to the respective avd folder 1.5 or 1.6

3)Restart the emulator.

4)Sign in using the google credentials.

5) If the emulator displays”Slide to open the keyboard” press ctrl+F11 to unlock it and then proceed.

The above steps are working fine for 1.5.

If the above system.img is not working then download the avd with system.img for 1.5 from the following URL

Voice Action for Android

Leave a comment

The Google supports the users to speak with Android. The people can easily do their tasks through by voice action/commands. Voice actions means, it is a series of spoken commands that control the handset using the voice. It supports the making calls, sending text message, sending emails, listening to music, finding map direction, making the search and etc..
But these voice commands are supported only in android 2.2 handset.

How it works

Voice control was triggered by tapping a microphone icon on the touch-screen of an Android smartphone.Currently it is available for English speakers. The program will be pre-installed on Droid 2 smart phones. Other smart phones running on updated Android (2.2) Froyo software can get the feature by downloading an application from the Android Market, according to Google.


1. Call Contacts: Say “call [contact name] [phone type] Eg: Call David mobile
2. Call Businesses: Say “call [business name][location]” Eg: Call David mexico
3. Send Text Message: Say “send text to [recipient][message]”
Eg: Send text to David meeting at 3pm
4. Send E-Mail: Say “ send email to [recipient][subject][body]”
Eg: Send email to David meeting It will start at 3pm
5. View Map: Say “map of[address/city]” Eg: Map of India
6. Get Directions: Say “navigate to [address/city/business name]” Eg: navigate to the San Francisco
7. Search Google: Say “[your search query]” Eg: Images of the roses
8. Go to Website: Say “[go to website]” Eg: Go to mob world
9. Listen music: Say “listen to [artist/song/album]” Eg: Listen to the Rahman hits
10. Write a note: Say “note to self[message]” Eg: Note to self seminar will start at 4pm

Older Entries