Tuesday, August 20, 2013

My personal Avaniavittam reminders

Avaniavittam is a festival day when we change the sacred thread (poonal).

This time, I had missed a few things and had to get ready quickly.  I thought I would keep a Things to do for my own reference next year.

Week before

  1. Make sure you have
  2. Poonal
  3. Dharbai
  4. Powthiram
  5. Black Sesame
  6. Rice
  7. Sandhyavandhanam book
  8. All mantra details - like greeshma rithu, varsha rithu etc.



Day before

  1. Materials to make vadai and payasam
  2. Vaccum clean the place
  3. Saree for wife
  4. Silk veshti
  5. Alarm



Tuesday, August 13, 2013

The Set

A common pattern in an interview is to ask for a data structure that would store a collection of items.  In Java, there are three types of objects that holds collection of data - Map, Set and List.

Here is a tip that would make sure that you choose an appropriate data type: Set should be your default choice.  A choice for a List should be based on you reasoning yourself out of using a Set.

Why?
Set has this data structure called HashSet.  It is super efficient.  Let us see this table for CURD operations.


HashSetArrayListLinkedList
C - Add to Collection
1
n
1
R - Find in Collection
1
lg n if sorted
n otherwise
n
D - Remove from Collection
1
n remove and move all elements
1 (finding will take n. but removing will be 1)

As you can see, HashSet is super-efficient in all cases.

When should I not use Set?

1. If your collection can allow duplicates
2. If you need to maintain an ordering of some kind.

Always use a Set by default.  Set is wonderful.

Android App not getting published

I created an Android App.  I followed all steps given here

I waited for almost two days.  The App did not get published.  It usually takes 5-24 hrs to get published.

Then I figured out that I had uploaded APKs under Alpha, Beta and Production.  But the App had remained in Alpha.  So, I moved the application to Production.

Here is the screenshot of the page:

Developer Console -> Your App -> APK -> Production tab -> Move to (drop-down)-> Choose Production.

Thursday, August 1, 2013

Android: Wake Up - Mistakes that I made

I had been working on a very simple Android Alarm App.  The users would set up an alarm after certain period of time.  When the time for Alarm arrives, the BroadcastReceiver defined in our application receives a signal.  If the phone is in lock mode, we have to wake the phone up and display to the user that it is time.

To wake the phone up, I am using android.os.PowerManager and PowerManager.WakeLock.

  1. I had tried waking the phone up from inside BroadcastReceiver.  It should be done from Activity's onCreate() method.
  2. The parameters that I passed for getting a new WakeLock were not working right.  In fact, I don't know which is the correct parameter I should use.  I am now using a deprecated parameter which is the only thing that is working for me.  The method is PowerManager'sInstance.newWakeLock().  The first parameter is levelAndFlags - I am using PowerManager.SCREEN_DIM_WAKE_LOCK.  I know I will have to use a combination of different non-deprecated flags.  But, I have not figured it out yet.
  3. Always release the WakeLock in onFinish(), onPause(), onStop() methods.