I know dividends are given when the company makes a profit/gets new lucrative projects OR wants to reward its shareholders to hold on with them in a falling market! I've been a beneficiary of them for the above-mentioned reasons
Just my take....though they may declare dividends for other reasons too! I cannot state the other reasons though.
Whenever any company declares dividend, see in bse & nse site and see the record date for dividend. buy before ex-dividend / record date and sell after the record date. you will get eligible for the dividend