Monday, June 29, 2009

Http Post In android

HttpResponse response;
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httpost = new HttpPost("url");

httpost.setHeader("Content-Type", "application/x-www-form-urlencoded");
//Input the user id and authentication key here

StringEntity message = new StringEntity("");

ResponseHandler responseHandler = new BasicResponseHandler();

String responseBody = httpclient.execute(httpost, responseHandler);
responseBody = " Sent!";
return responseBody;

Concurrency In using AsyncTask class (Android1.5)

I found that two AsyncTasks do not work concurrently. I investigated a bit and found a workaround .AsyncTask allows the app to do a task on a thread other than the UI thread. But IIUC, it only provides a single thread on which a queue of tasks is performed. Therefore, if one of the task is to wait on some event (n/w or sleep) then all other tasks will wait for it to finish.

To elaborate with the coding example:

public class MyTask extends AsyncTask<...>
{ ... }

// On the UI thread execute two tasks
MyTask mt1 = new MyTask().execute(args);

MyTask mt2 = new MyTask().execute(args);

In the above code both the execute calls will return immediately and free up
the UI thread; however mt1 will be executed first and mt2 will have to wait
until mt1 finishes.

Thanks to the android's open source, we can see implementation of AsyncTask.

I copied as in my project and changed the value
of CORE_POOL_SIZE to 5. This makes the thread pool to use 5 threads to
multiplex the queued AsyncTasks. This indeed solved my problem. Now if mt1
blocks on a sleep; mt2 goes ahead and finishes its job.

Sunday, June 28, 2009

Chicken Biryani ..Luch time:-)

Chicken biryani – Malabar ishtyle.

Finally i tried my hand in making Chicken Biryani Kerala Ishtyle ....:-)..It was an experiment but to tell you the truth i loved it . Even my mom and dad loved it..:-)

I would like to thank my Mom for helping me in making this experimental dish for my family

Once you have made biryani you will see that it is more of a method than exact measure ( except for cooking the rice).

Here are some pictures to get you inspired.

Cooking the rice:

Soak the rice in water for 30min or so prior to cooking. Drain off the water.

Add ghee( a must for authentic taste), cloves, cardamon and cinnamon. Add the rice. Stir well. Add water and salt. ( For 3 cups of rice, I used 5 3/4 water). Cook covered. When all water is evaporated, shut off the flame and keep covered for a few more minutes. In the meanwhile avoid stirring. You can fluff with a fork after it has finished cooking


Cooking the chicken


Layering the rice and chicken


Also fry onions, raisins and cashews.

Bake for 15- 20 minutes.

Serve warm with raita ,curd , achar .