I had written method to get the pixels from dip but it is not working. It give me runtime error.
Actually I was running this method in separate class and initialized
You can add the dp value in dimen.xml and use
int pixels = getResources().getDimensionPixelSize(R.dimen.idDimension);
It's easier...